Question
WRITE THE CODE IN JAVA !!! The following class files are provided. You have files for Locomotive , FuelType , Automobile , and SUV .
WRITE THE CODE IN JAVA !!!
The following class files are provided.
You have files for Locomotive, FuelType, Automobile, and SUV.
Add Car that extends Automobile and has zeroToSixty as instance variable. Default value of 3 seconds.
Add Truck that extends Automobile and has numOfWheels as instance variable. Default value of 16.
Add a class Train that extends Locomotive Has FuelType as Solar, as default - you have to update the FuelType Has numOfCars with 4 as its default Has numOfEngines with 1 as its default Create a class AirPlanes that extends Locomotive Has routes - DOMESTIC or INTERNATIONAL - Make it ENUM type.
Please note: each class will have necessary constructors, setters() and getters() as required, and the toString() method.
Upload all java source files as 1 zip file.
THE FOLLOWING ARE THE FILES FOR Locomotive, FuelType, Automobile, and SUV. DESCRIBED IN THE BEGING
files for Locomotive ::
public abstract class Locomotive
{
private FuelType ft;
public void setFuelType(FuelType f) { ft = f; }
public FuelType getFuelType() { return ft; }
}
files for FuelType::
public enum FuelType
{
DIESEL, GAS, HYBRID, ELECTRIC
}
files forAutomobile::
public class Automobile extends Locomotive
{
private String mode;
private String manufacturer;
private String owner;
private double price;
public Automobile() { this("LAND"); }
public Automobile(String m) { this.setMode(m); }
public Automobile(String ma, String o, double p) {
this.setManufacturer(ma); this.setOwner(o); this.setPrice(p);}
public void setMode(String m) { mode = m; }
public String getMode() { return mode; }
public void setManufacturer(String m) { manufacturer = m; }
public String getManufacturer() { return manufacturer; }
public void setOwner(String o) { owner = o; }
public String getOwner() { return owner; }
public void setPrice(double p) { price = p; }
public double getPrice() { return price; }
public String toString()
{ String tmp = "Uses Fuel Type: " + this.getFuelType() + " Mode is: "
+ mode;
tmp += " Manufacturer is: " + manufacturer + " Owner is: " +
owner;
tmp += " Price is: " + price;
return tmp; }
}
files for SUV::
public class SUV extends Automobile
{
private static int numOfSUVs = 0;
public SUV() { super("NA","NA", 0.0); numOfSUVs++; }
public SUV(String ma) { super(ma, "NA", 0.0); numOfSUVs++; }
public SUV(String ma, String o) { super(ma, o, 0.0); numOfSUVs++;}
public SUV(String ma, String o, double p) { super(ma, o, p);
numOfSUVs++;}
public static int getNumOfSUVs() { return numOfSUVs; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started