Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Locomotiveimage text in transcribed, FuelTypeimage text in transcribed, Automobileimage text in transcribed, and SUVimage text in transcribed.

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 Locomotiveimage text in transcribed, FuelTypeimage text in transcribed, Automobileimage text in transcribed, and SUVimage text in transcribed. DESCRIBED IN THE BEGING

files for Locomotiveimage text in transcribed ::

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions