Java OOP GUIDE / WORK VEHICLE SUPERCLASS Topics
TASK –
PART 1 – SETUP & EXAMINATION – THE VEHICLE CLASS Copy
and paste the following Vehicle and VehicleTester
classes. Examine them to make sure you
understand how they work.
TASK –
PART 2 – SETUP – VEHICLE CLASS Copy
and paste the following Truck class that inherits from Vehicle. Examine it closely.
TASK –
PART 3 – TESTING TRUCK Inside
the Vehicle tester class, inside main, create a Truck object. You determine the parameters for your
truck. Call
the requiredHitch() method from the Truck class. Call
the toString() method that is inherited from the Vehicle class. TASK –
PART 4 - TOSTRING Create
a toString() method inside truck that incorporates all instance
variables from Truck and Vehicle. Now
run your tester class again. Notice
that the new toString() method is called. TASK –
PART 5 – CAR CLASS Create
the Car class with the following specifications: ·
It
extends the Vehicle class. ·
It
has the following instance variables: public int seatingSpots; public boolean hasLeatherInterior;
public double fuelEfficiencyPer100km;
//usually 5L to 10L per 100km ·
It
has a constructor that gets a parameter for each of the instance variables. ·
It
has the following method that returns true is the fullEfficiencyPer100km is
6L or less. Otherwise, it returns false. public boolean
isFullEfficient() ·
It
has a toString method that incorporates all
instance variables from Car and Vehicle. TASK –
PART 6 – TESTING Inside
the Vehicle tester class, inside main, create a Car object. You determine the parameters for your
truck. Call
the isFullEfficient() method from the Car class. Call
the toString() method. |
|||
|