13/13 part 1 i need help!


#1

Coffee.java:1: error: class, interface, or enum expected
public Coffee() {
^
Coffee.java:4: error: class, interface, or enum expected
public void addSugar(int cubes) {
^
Coffee.java:7: error: class, interface, or enum expected
}
^
Coffee.java:9: error: class, interface, or enum expected
public static void main(String[] args) {
^
Coffee.java:11: error: class, interface, or enum expected
myOrder.addSugar(2);
^
Coffee.java:12: error: class, interface, or enum expected
myOrder.isFull();
^
Coffee.java:13: error: class, interface, or enum expected
}
^
7 errors

ublic 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();
	}
}

#2

I don't know how to do this!!!


How do i take a screen shot?
#3

how do I get code? im SO stuck...


#4

is it you full code?
if yes then where is your class?

class Coffee{

and
Modify the Coffee class so that it inherits from the Beverage class as instruction says

to inherit use extends keyword


#5

this is my code

class Coffee {

public Coffee() {

}

public void addSugar(int cubes) {

	System.out.println("You added " + cubes + " sugar cubes.");

}

public static void main(String[] args) {

}

}


#6

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.


#7

ok ill try it thank you!


#8

um it didn't work... this is the code

class Coffee extends Bevrage{

public Coffee() {

}

public void addSugar(int cubes) {

	System.out.println("You added " + cubes + " sugar cubes.");

}

public static void main(String[] args) {

}

}


#9

I got the help I needed thx!!!


#12

What is wrong with:

class Coffee extends Beverage{
	
	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();
      
  }
}

I just don't know what I did?


#13

i dont know im not so good... and dont do this alot


#14

well its a bug in codeccademy , first make the coffee object then click run then make these two objects

myOrder.addSugar(2);
myOrder.isFull();

and again click run


#15

Hi, did you report the bug to code academy?. I did, but I get no answer. Thank you.


#16

I made it work by doing the steps one at a time.

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


#17

I did it and the lesson was completed. Thanks guys (y)


#18

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.