Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create this assignment below using Java. Follow the rules below and create the r

ID: 3859374 • Letter: C

Question

Create this assignment below using Java.

Follow the rules below and create the required classes for a good rate.

Contents

Parent Class: Vehicle
Child Classes: Car, Boat, Airplane
Overriding
Implementing Comparable
Steerable Interface
Collection Data
Collection Behavior
Testing

-----------------------------------------------------------------------------

Parent Class: Vehicle
This abstract parent class has private instance variables, mutator methods, accessor methods, and constructor parameters for:

- Year manufactured
- Make
- Model

Child Classes: Car, Boat, Airplane
Class Vehicle has child classes which have additional private instance variables, mutator methods, accessor methods, and constructor parameters for:

- Car has “int horsepower”
- Boat has “boolean motorized”
- Airplane has “int maximumHeightFeet”

Overriding
Each of the Car, Boat, and Airplane classes must override the equals() and toString() methods. Cars are equal if their horsepower is within 10 of one another. Boats are equal if they are both motorized, or both unmotorized. Airplanes are equal if their maximumHeightFeet is within 1000 of one another. Always use the @Override annotations. The toString methods must return a String in these formats:

This car is a 1999 Toyota Corrola with 140 hp.

This boat is a 1980 Bayliner Extreme (with motor).

This airplane is a 1998 ABC Motors Comac that can reach 10000 feet.

Implementing Comparable
Each of the Car, Boat, and Airplane classes must implement the Comparable interface (with no java compiler warnings). Cars that have more horsepower are “bigger”. Boats that are newer are “bigger”. Airplanes that can reach higher maximum heights are “bigger”.

Steerable Interface
Each of the Car, Boat, and Airplane classes must implement the Steerable interface that you create (with no java compiler warnings). This interface has methods to accelerate(), steerLeft(), and steerRight(). Cars that accelerate simply System.out.println(“fire pistons, turn wheels”). Boats that accelerate simply System.out.println(“jet water”). Airplanes that accelerate simply System.out.println(“fire engines on wings”). Cars that steer left simply System.out.println(“turn wheels left”). Boats that steer left simply System.out.println(“turn tiller left”). Airplanes that steer left simply System.out.println(“lift wing flaps to turn left”). Cars that steer right simply System.out.println(“turn wheels right”). Boats that steer right simply System.out.println(“turn tiller right”). Airplanes that steer right simply System.out.println(“lift wing flaps to turn right”).

Collection Data
Create three collections of Vehicles as follows:

Vehicle Type

Year

Make

Model

Car

2000

Lamborghini

Diablo

Horsepower 700

Car

1997

Dodge

Ram

Horsepower 175

Car

1940

Buggati

Veyron

Horsepower 135

Car

2014

Honda

Civic

Horsepower 143

Car

2011

Honda

Civic

Horsepower 143

Car

1999

Toyota

Corrola

Horsepower 140

Boat

1980

Bayliner

Extreme

Motorized

Boat

2014

Bayliner

Extreme II

Motorized

Boat

2000

American Skier

Skier Supreme

Unmotorized

Boat

2010

Boesch

Journey

Unmotorized

Airplane

1998

ABC Motors

Comac

10000 feet max.

Airplane

1940

Boeing

84

45000 feet max.

Airplane

2012

Boeing

737

80000 feet max.

Airplane

2014

Abrams

Motorhead

70000 feet max.

Collection Behavior
Add the above vehicles in the above-specified order. Print out the collections before and after sorting them via Collections.sort().

Testing
Create a jUnit test to test the accessors, mutators, constructors, equals(), toString(), and compareTo() methods of each of your Vehicle, Car, Boat, and Airplane classes. Create at least two methods to test each of these methods for each of your classes.

Vehicle Type

Year

Make

Model

Car

2000

Lamborghini

Diablo

Horsepower 700

Car

1997

Dodge

Ram

Horsepower 175

Car

1940

Buggati

Veyron

Horsepower 135

Car

2014

Honda

Civic

Horsepower 143

Car

2011

Honda

Civic

Horsepower 143

Car

1999

Toyota

Corrola

Horsepower 140

Boat

1980

Bayliner

Extreme

Motorized

Boat

2014

Bayliner

Extreme II

Motorized

Boat

2000

American Skier

Skier Supreme

Unmotorized

Boat

2010

Boesch

Journey

Unmotorized

Airplane

1998

ABC Motors

Comac

10000 feet max.

Airplane

1940

Boeing

84

45000 feet max.

Airplane

2012

Boeing

737

80000 feet max.

Airplane

2014

Abrams

Motorhead

70000 feet max.

Explanation / Answer

//Vehicle class

class Vehicle

{

String regno;

int model;

Vehicle(String r, int m)

{

regno=r;

model=m;

}

void display()

{

System.out.println("Registration no: "+regno);

System.out.println("Model no: "+model);

}

}

class Twowheeler extends Vehicle

{

int noofwheel;

Twowheeler(String r,int m,int n)

{

super(r,m);

noofwheel=n;

}

void display()

{

System.out.println("Two wheeler tvs");

super.display();

System.out.println("No. of wheel : " +noofwheel);

}

}

class Threewheeler extends Vehicle

{

int noofleaf;

Threewheeler(String r,int m,int n)

{

super(r,m);

noofleaf=n;

}

void display()

{

System.out.println("Three wheeler auto");

super.display();

System.out.println("No. of leaf:" +noofleaf);

}

}

class Fourwheeler extends Vehicle

{

int noofleaf;

Fourwheeler(String r,int m,int n)

{

super(r,m);

noofleaf=n;

}

void display()

{

System.out.println("Four wheeler car");

super.display();

System.out.println("No. of leaf:" +noofleaf);

}

}

class VehicleDemo

{

public static void main(String arg[])

{

Twowheeler t1;

Threewheeler th1;

Fourwheeler f1;

t1=new Twowheeler("TN74 12345", 1,2);

th1=new Threewheeler("TN74 54321", 4,3);

f1=new Fourwheeler("TN34 45677",5,4);

t1.display();

th1.display();

f1.display();

}

}