Question: Given the class Vehicle as shown in the answer box below, create a class Car that extends the Vehicle class with the following components:
Given the class Vehicle as shown in the answer box below, create a class Car that extends the Vehicle class with the following components: 1. 2 data members, price and make. 2. A constructor with 3 parameters, price, make, and owner, to initialize the object's data members including the base class' owner_name. (3) 3. Write the toString() method that returns the string including all instance data field values, e.g., "Bob Smith Toyota $30000". (4) 4. Implement the Comparable interface and the required method so that two cars can be compared on make, then on owner name. (5) public class Vehicle { private String owner_name; public Vehicle() { owner_name = "Unkown"; } public Vehicle(String owner) { owner_name = owner; } } //FIXME - Provide the Java code for Car class as required
Step by Step Solution
3.55 Rating (155 Votes )
There are 3 Steps involved in it
Here is the Java code for the Car class as required public class Car extends Vehicle implements Comp... View full answer
Get step-by-step solutions from verified subject matter experts
