In Java, Test file(Test.java) package for_vehicles;   public class Test {           public static void main(String[] args) {                                  Automobile a1 = new Sedan("Honda", 4, 25, 5, "Civic", SedanType.SMALL, 4, 150.0);                 Automobile a2 = new Truck("Chevy", 4, 20, 3, "Silverado", 4, 13000, TruckTypes.PICKUP);                                  TwoWheeler t1 = new Bicycle("Trek", 2, "Skye SLX", 10, 110, true, true);                 TwoWheeler t2 = new MotorCycle("BMW", 2, "R18", 761, 50, 91);                                  Vehicle[] veharr = {a1, a2, t1, t2};                                  for(Vehicle v : veharr) {                         System.out.println(v.toString());                 }                                  System.out.println("The total number of Vehicles should be 4: ");                 System.out.println(Vehicle.numVehicles);                          }   } The link for "here": https://stackoverflow.com/questions/5385894/how-to-zip-up-a-java-eclipse-project-so-it-can-be-easily-unfolded-onto-another-c

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In Java,

Test file(Test.java)

package for_vehicles;

 

public class Test {

 

        public static void main(String[] args) {

                

                Automobile a1 = new Sedan("Honda", 4, 25, 5, "Civic", SedanType.SMALL, 4, 150.0);

                Automobile a2 = new Truck("Chevy", 4, 20, 3, "Silverado", 4, 13000, TruckTypes.PICKUP);

                

                TwoWheeler t1 = new Bicycle("Trek", 2, "Skye SLX", 10, 110, true, true);

                TwoWheeler t2 = new MotorCycle("BMW", 2, "R18", 761, 50, 91);

                

                Vehicle[] veharr = {a1, a2, t1, t2};

                

                for(Vehicle v : veharr) {

                        System.out.println(v.toString());

                }

                

                System.out.println("The total number of Vehicles should be 4: ");

                System.out.println(Vehicle.numVehicles);

                

        }

 

}

The link for "here": https://stackoverflow.com/questions/5385894/how-to-zip-up-a-java-eclipse-project-so-it-can-be-easily-unfolded-onto-another-c

The following diagram shows a vehicle inventory system. Here's how you should read the diagram:
• Each rectangle is a separate class, and the name of the class is at the top (such as Vehicle).
• The items inside the classes are the instance variables (such as numWheels, which is an int; or type, which
is a SedanTypes enum; or mpg, which can be either a float or a double). These instance variables should all
be marked as protected, not private.
If the class name is in /TALICS, then the class is an abstract class.
If an instance variable is underlined, then it is a static member of the class.
The arrows indicate inheritance relationships between classes: the child points up to its parent.
The enumerations (enums) are separate classes. (In Eclipse, you create an enum File -> New -> Enum.)
Vehicle
E numVehicles: Integer
Q manufacturer: String
EnumWheels: Integer
Automobile
TwoWheeler
E model: String
mpg: Real
numSeats: Integer
Eweight: Integer
model: String
Sedan
Truck
MotorCycle
Bicycle
E type: SedanTypes
Q numAxles: Integer
Q caloriesBurnedPerHour: Integer
Q hasGears: Boolean
Empg: Real
,numCylinders: Integer
EgrossVehicleMass: Integer
type: TruckTypes
horsepower: Integer
Ehorsepower: Real
hasSuspensions: Boolean
« Enumeration »
« Enumeration »
SedanTypes
TruckTypes
Small
Mini
O Pickup
O Family
- Large
O Luxury
O Tow
O Flatbed
Semi
Transcribed Image Text:The following diagram shows a vehicle inventory system. Here's how you should read the diagram: • Each rectangle is a separate class, and the name of the class is at the top (such as Vehicle). • The items inside the classes are the instance variables (such as numWheels, which is an int; or type, which is a SedanTypes enum; or mpg, which can be either a float or a double). These instance variables should all be marked as protected, not private. If the class name is in /TALICS, then the class is an abstract class. If an instance variable is underlined, then it is a static member of the class. The arrows indicate inheritance relationships between classes: the child points up to its parent. The enumerations (enums) are separate classes. (In Eclipse, you create an enum File -> New -> Enum.) Vehicle E numVehicles: Integer Q manufacturer: String EnumWheels: Integer Automobile TwoWheeler E model: String mpg: Real numSeats: Integer Eweight: Integer model: String Sedan Truck MotorCycle Bicycle E type: SedanTypes Q numAxles: Integer Q caloriesBurnedPerHour: Integer Q hasGears: Boolean Empg: Real ,numCylinders: Integer EgrossVehicleMass: Integer type: TruckTypes horsepower: Integer Ehorsepower: Real hasSuspensions: Boolean « Enumeration » « Enumeration » SedanTypes TruckTypes Small Mini O Pickup O Family - Large O Luxury O Tow O Flatbed Semi
Your Homework Assignment:
1. In Eclipse, create a new Java Project. File
-> New -> Java Project. Call it Vehicles, and use project folder as
root for sources and class files; press "Finish" and say ok to the warning.
2. Making sure Vehicles is highlighted blue, create a new package. File -> New -> Package. Call it for_vehicles.
3. Create seven classes according to the diagram above inside your for_vehicles package. Aside from
protected instance variables and the constructor, include only a toString() method in each class, which should
also incorporate the toString() of the parent class using super (). Every time a Vehicle is created, the
numVehicles variable should be incremented.
4. Create the two enums according to the diagram above.
5. You will know your homework is ready to submit to this assignment when you can run it with the following test
file e and it outputs approximately the following (your toString () for each class doesn't have to be exactly the
same as mine):
This SMALL sedan has 4 cylinders and 150.0 horsepower. It is called Civic and it makes 25.0 miles per gallon and
has 5 seats. This vehicle is made by Honda and has 4 wheels.
This PICKUP truck has 4 axles and is 13000 lbs in mass. It is called Silverado and it makes 20.0 miles per gallo
n and has 3 seats. This vehicle is made by Chevy and has 4 wheels.
This bicycle burns 110 calories per hour and does have gears and does have suspensions. It is called Skye SLX an
d is 10 lbs. This vehicle is made by Trek and has 2 wheels.
This motorcyle makes 50.0 miles per gallon and has 91 horsepower. It is called R18 and is 761 lbs. This vehicle
is made by BMW and has 2 wheels.
The total number of Vehicles should be 4:
4
Follow the guidelines in the first answer here for exporting your files from Eclipse, and then upload your zipped
folder to this Canvas assignment.
Transcribed Image Text:Your Homework Assignment: 1. In Eclipse, create a new Java Project. File -> New -> Java Project. Call it Vehicles, and use project folder as root for sources and class files; press "Finish" and say ok to the warning. 2. Making sure Vehicles is highlighted blue, create a new package. File -> New -> Package. Call it for_vehicles. 3. Create seven classes according to the diagram above inside your for_vehicles package. Aside from protected instance variables and the constructor, include only a toString() method in each class, which should also incorporate the toString() of the parent class using super (). Every time a Vehicle is created, the numVehicles variable should be incremented. 4. Create the two enums according to the diagram above. 5. You will know your homework is ready to submit to this assignment when you can run it with the following test file e and it outputs approximately the following (your toString () for each class doesn't have to be exactly the same as mine): This SMALL sedan has 4 cylinders and 150.0 horsepower. It is called Civic and it makes 25.0 miles per gallon and has 5 seats. This vehicle is made by Honda and has 4 wheels. This PICKUP truck has 4 axles and is 13000 lbs in mass. It is called Silverado and it makes 20.0 miles per gallo n and has 3 seats. This vehicle is made by Chevy and has 4 wheels. This bicycle burns 110 calories per hour and does have gears and does have suspensions. It is called Skye SLX an d is 10 lbs. This vehicle is made by Trek and has 2 wheels. This motorcyle makes 50.0 miles per gallon and has 91 horsepower. It is called R18 and is 761 lbs. This vehicle is made by BMW and has 2 wheels. The total number of Vehicles should be 4: 4 Follow the guidelines in the first answer here for exporting your files from Eclipse, and then upload your zipped folder to this Canvas assignment.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY