JAVA Project:
Create two classes: Vehicle and
UnmannedVehicle. The class UnmannedVehicle is
a
subclass that extends the class Vehicle.
You are also required to write the driver class VehicleInformation,
which allows you to
test your implementation of Vehicle and UnmannedVehicle.
The following are implementation details for the classes you need
to implement (provided
when not self-evident):
• Vehicle class
o Private fields
String vehicleName
String vehicleManufacturer
int yearBuilt
int cost
o Public class constant field
int MINYEARBUILT equals to
1886 (as modern cars were invented in 1886)
o getter and setter methods depending on your program design
o void printInfo() method: Print out the
information of the Vehicle, including its
name, manufacturer, year built, and cost. An example of the output
of this
method is as follows:
Vehicle Information:
Name: RAV4
Manufacturer: Toyota
Year built: 2021
Cost: 38000
Note: As shown in the above example output, starting from the
second line,
each line has three spaces at the beginning.
• UnmannedVehicle class
o Extends the Vehicle class.
o Additional private fields: int SAE and int rating
§ SAE (level of automation) is between 0 and 5 and the rating
between 0
and 10.
o Public class constant fields for min and max SAE and, min and max
rating
o getter and setter methods depending on your program design
o Overrides the void printInfo() method of the superclass. The
method not only
print out the information of name, manufacturer, year built, and
cost, but also
print out the information about SAE and rating. An example of the
output this
method is as follows.
Vehicle Information:
Name: Model Z
Manufacturer: Tesla
Year built: 2022
Cost: 88000
SAE: 3
Rating: 7
Your VehicleInformation.java would use Vehicle and UnmannedVehicle
classes.
To do that, it has two methods Vehicle buildVehicle() and
UnmannedVehicle
buildUnmannedVehicle() that validates the information before
calling the
Vehicle/UnmannedVehicle constructor. Information to validate are
builtYear, cost, SAE and
rating. These methods will return the object reference if
successful, null otherwise.
Your main method should demonstrate the (tentative) creation of 2
unmanned and 2 regular
vehicles.
Below is the sample output.
Sample Output
Error: invalid yearBuilt. Object not created!
Vehicle Information:
Name: RAV4
Manufacturer: Toyota
Year built: 2021
Cost: 38000
Error: invalid sae. Object not created!
Vehicle Information:
Name: Model S
Manufacturer: Tesla
Year built: 2022
Cost: 80000
SAE: 2
Rating: 3
Another Sample Output
Create two classes: Vehicle and UnmannedVehicle. The class UnmannedVehicle is a subclass that extends the class Vehicle. You are also required to write the driver class Vehicle Information, which allows you to test your implementation of vehicle and UnmannedVehicle. The following are implementation details for the classes you need to implement (provided when not self-evident): • Vehicle class o Private fields . String vehicleName • String vehicle Manufacturer int yearBuilt int cost o Public class constant field • int MINYEARBUILT equals to 1886 (as modern cars were invented in 1886) o getter and setter methods depending on your program design o void printInfo() method: Print out the information of the vehicle, including its name, manufacturer, year built, and cost. An example of the output of this method is as follows: Vehicle Information: Name: RAV4 Manufacturer: Toyota Year built: 2021 Cost: 38000 Note: As shown in the above example output starting from the second line, each line has three spaces at the beginning.
• Unmanned Vehicle class o Extends the vehicle class. o Additional private fields: int SAE and int rating • SAE (level of automation) is between 0 and 5 and the rating between 0 and 10. o Public class constant fields for min and max SAE and, min and max rating o getter and setter methods depending on your program design o Overrides the void printInfo() method of the superclass. The method not only print out the information of name, manufacturer, year built, and cost, but also print out the information about SAE and rating. An example of the output this method is as follows. Vehicle Information: Name: Model Z
Manufacturer: Tesla Year built: 2022 Cost: 88000 SAE: 3 Rating: 7 Your VehicleInformation.java would use Vehicle and Unmannedvehicle classes. To do that, it has two methods Vehicle buildVehicle() and Unmanned Vehicle buildUnmanned Vehicle() that validates the information before calling the Vehicle/Unmanned Vehicle constructor. Information to validate are built Year, cost, SAE and rating. These methods will return the object reference if successful, null otherw Your main method should demonstrate the (tentative) creation of 2 unmanned and 2 regular vehicles. Below is the sample output.
Sample Output Error: invalid yearBuilt. Object not created! Vehicle Information: Name: RAV4 Manufacturer: Toyota Year built: 2021 Cost: 38000 Error: invalid sae. Object not created! Vehicle Information: Name: Models Manufacturer: Tesla Year built: 2022 Cost: 80000 SAE: 2 Rating: 3
Another Sample Output Vehicle Information: Name: zs Manufacturer: MG Year built: 2018 Cost: 35000 Vehicle Information: : Name: RAV4
Manufacturer: Toyota Year built: 2021 Cost: 38000 Vehicle Information: Name: AutoLab Manufacturer: RMIT Year built: 2002 Cost: 198000 SAE: 5 Rating: 9 Vehicle Information: Name: RIT Manufacturer: Rivian Year built: 2022 Cost: 90000 SAE: 4 Rating: 8
JAVA Project: Create two classes: Vehicle and UnmannedVehicle. The class UnmannedVehicle is a subclass that extends the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
JAVA Project: Create two classes: Vehicle and UnmannedVehicle. The class UnmannedVehicle is a subclass that extends the
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!