Write a usevehicle class to instantiate one vehicle object


Write a UseVehicle class to instantiate one Vehicle object, one Car object, one MotorCycle object, and display each object’s values.

I made up the other classes (Car.java, MotorCycle.java, and Vehicle.java)

Car.java: public class Car extends Vehicle

{

public Car(int wheels, int mpg)

{

super(wheels, mpg);

}

}

MotorCycle.java: public class MotorCycle extends Vehicle

{

public MotorCycle(int wheels, int mpg)

{

super(wheels, mpg);

}

}

Vehicle.java: public class Vehicle

{

public int wheels;

public int mpg;

public Vehicle(int wheels2, int mpg2)

{

wheels = wheels2;

mpg = mpg2;

}

public int getWheels()

{

return wheels;

}

public double getMpg()

{

return mpg;

}

public String toString(int mpg)

{

String vehicleString = "Number of wheels is: " + wheels + " mpg is: " + mpg;

return vehicleString;

}

}

Request for Solution File

Ask an Expert for Answer!!
Other Subject: Write a usevehicle class to instantiate one vehicle object
Reference No:- TGS0641176

Expected delivery within 24 Hours