I would greatly appreciate any help with my Programming project


That is my project that I've just started. I would like to thank anyone in advance for any help.

I'm still on part 1 right now. my first question is about the Vehicle class. I'm supposed to include the method [b]public abstract String getType();[/b]
--since it's an abstract method, the Vehicle class would have to abstract itself, correct? if the Vehicle class is abstract, then how can I instantiate Vehicle object in the VehicleTester class? I thought you were allowed to instantiate objects from abstract classes, yet the instructions include "[italic]test the Vehicle and Car classes by constructing several instances of
vehicles and cars, and printing enough information to test the accessor and toString
methods of these classes."[/italic]

My second question is about the method [b]public int compareMakeTo(Vehicle other)[/b] which compares two vehicles on the alphabetic order of their makes. I'm not exactly sure how I'm supposed to compare the strings. right now i return [italic]getMake().compareTo(other.getMake());[/italic], though I really don't know if that's right...

Again, thanks for any help. I might have a few more questions in the future.


  • Straight from java's website: If a class includes abstract methods, the class itself must be declared abstract, as in:
    public abstract class GraphicObject {
    // declare fields
    // declare non-abstract methods
    abstract void draw();

    Since the vehicle class is abstract, when creating a new vehicle simply extend the new vehicle class as an vehicle, ex:
    public class Toyota extends Vehicle
    In your testing code you wouldnt instantiate the vehicle class directly, you would instantiate toyota, honda, etc.

    Now as for the compare method you could do something like:
    public bool compareMake(Vehicle make)
    //assuming getMake() returns a string value
    return true;
    return false;
  • Thank you fine sir!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!