Hi guys, this has been bugging me for a while and I'd appreciate any help anyone could offer.
Basically I am running a boating simulation and I have all of the "harder" parts done but one error is holding me back from compiling my code.
I won't go into detail about the simulation but basically I have a Boat super class and extended from this are the sub classes; cruiser, speedboat, and jetski.
My problem is when it comes to accessing methods in the cruiser, speedboat, and jetski classes.
For example here is a section of my code (the context is unimportant)
The getBoat method expects a boat to be returned but since the Cruiser class extends the Boat class, I thought it would be accpetable to return a cruiser? If I create the variable "v" as a cruiser I still get a type mismatch error.
So my question is how can I get this part of my method to convert or accept the object so that there is no type mismatch.
I'm happy to quickly provide any other information that may help you solve my problem.
Regards
GX
Basically I am running a boating simulation and I have all of the "harder" parts done but one error is holding me back from compiling my code.
I won't go into detail about the simulation but basically I have a Boat super class and extended from this are the sub classes; cruiser, speedboat, and jetski.
My problem is when it comes to accessing methods in the cruiser, speedboat, and jetski classes.
For example here is a section of my code (the context is unimportant)
Code:
if (getBoat(i).getType() == "cruiser"){
Boat v = getBoat(i);
return v;
finished = true;
}
So my question is how can I get this part of my method to convert or accept the object so that there is no type mismatch.
I'm happy to quickly provide any other information that may help you solve my problem.
Regards
GX
Comment