Question: Using your project from Lab 5, create a type of vehicle class (i.e. Car) which inherits from the Automobile class. 2. Your new vehicle should
Using your project from Lab 5, create a type of vehicle class (i.e. Car) which inherits from the Automobile class.
2. Your new vehicle should have a default constructor which sets all the class variables to default values and an overloaded constructor which calls the super class constructor and must have a minimum of three additional variables.
3. Each variable should use the private modifier and be encapsulated in your class.
4. See my example below for a Car. You may not use the example below.
JAVA
example:
public Car extends Automobile { private boolean sunroof; private boolean spoiler; private String transmissionType; public Car() { super(, 0, 0); this.sunroof = false; this.spoiler = false; this.transmissionType = ; } public Car(String make, String model, String numberOfDoors, boolean sunroof, boolean spoiler, String transmissionType) { super(make, model, numberOfDoors); this.sunroof = sunroof; this.spoiler = spoiler; this. transmissionType = transmissionType; } public boolean getSunroof() { return this.sunroof; } public void setSunroof(boolean sunroof) { this.sunroof = sunroof; } public boolean getSpoiler() { return this.spoiler; } public void setSpoiler(boolean spoiler) { this.spoiler = spoiler; } public String getTransmissionType() { return this.transmissionType; } public void setTransmissionType(String transmissionType) { this.transmissionType = transmissionType; } @Override public String toString() { String output = ; output += Make: + this.make + ; output += Model: + this.convertModel(this.model) + ; output += Number of Doors: + this.numberOfDoors + ; output += Sunroof: + this.sunroof + ; output += Spoiler: + this.spoiler + ; output += Transmission Type: + this.transmissionType; return output; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
