Inheritance Comments
Comments
-
@calo, doesn't matter. On a computer, each class is usually defined in its own file; the Java compiler can figure it all out.
-
I see now ...I made it eventually, although to public RocketCar(), I only type formula for rocket fuel and nothing else:
public RocketCar()
{
//constructorrocketFuel=10; }
And it worked (in accelerate I called the super accelerate and defined the rocketFuel similar as normal fuel and it worked). I wonder if u stated "contractor: It should call Car's constructor, but also set rocketFuel to 10.", if something more should be there or not.
-
I can't figure out why fuel stays at 20
-
how do I make the fuel go down
-
@jack, please update your email information. If you're interested, you can sign up for membership on Learneroo to get help when learning online.
-
It is updated
-
Hello.
I have correct output, but I changed private variables in class car to non-private.
Is it OK ?
my code: http://www.learneroo.com/user_answers/5096985764 -
Why, in the Student & Staff example, student1.super.toString() doesn't work? I get Error: cannot find symbol - class student1. I've created an instance of Student called student1.
-
I have:
if(speed <= maxSpeed && rocketFuel != 0)
{
speed+=2;
rocketFuel--;
}But its saying it doesn't like my maxSpeed...
Main.java:14: error: maxSpeed has private access in Car
if(speed <= maxSpeed && rocketFuel != 0)
^Why?
-
Hi!
I didn't succeed resolve it.. -
@Raz, you first need to address the compile errors. Don't call
super()
from within a regular method, instead callsuper.methodName()
. And don't try accessing a Car's private fuel, RocketCar only deals with rocketFuel. -
I'm didn't understand What am I being asked to do?
-
@Raz, I added a hint that spells it out in order.
-
my code - Didn't work:/
-
You still need to fix your accelerate method, it's not following the correct syntax. See the correct solution for how to fix it.
-
so with this line of code:
System.out.println(i +". "+ rc);when we say + rc it calls the toString() method of class Car?
can you please explain it why? should't it be something like
+rc.toString()) ; -
As mentioned above, Java has a built-in shortcut that calls the
toString
method of an object when you print it. SoSystem.out.println(i +". "+ rc);
is equivalent toSystem.out.println(i +". "+ rc.toString() );
-
why does super.Car() not work?
-
What method is .Car()?
calo
Jan 27, 2:00 PMIs it ok that rocketCar is defined before Car ?