I was having trouble with this too, but got it to work. It looks like in your first attempt, you didn’t extend the Beverage class to Coffee… so the isFull method couldn’t work on myOrder.
My code is below:
class Coffee extends Beverage{ //This is the part you missed
public Coffee() {
}
public void addSugar(int cubes) {
System.out.println("You added " + cubes + " sugar cubes.");
}
public static void main(String[] args) {
Coffee myOrder = new Coffee();
myOrder.addSugar(2);
myOrder.isFull(); //This method could not act on myOrder because of the missing inheritance noted above.
}
}
Hope the explanation helps. Let me know if you’re still having trouble.
Start off by doing Coffee myOrder = new Coffee(); ( Make sure its a O not zero) then press run, then do myOrder.addSugar(2); then press run again it should work
Then do public Coffee extends Beverage in the class description on the top of your source code. press Run, and then the last step which is
MyOrder.isFull();
It worked for me doing this. Step by step and make sure no typing errors. Gl bruh