The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 364 Weeks Ago, 2 Days Ago |
| Questions Answered: | 1850 |
| Tutorials Posted: | 1850 |
Graduate in Biology and Nutrition, MBA Finance
Florida State University
Aug-2000 - Jul-2007
Ass. Relationship Manager
Penn-Florida
Mar-2009 - Feb-2016
Java Program Demonstrating Inheritance you are writing a program for a car rental company. This company rents more than one type of vehicle to customers and the employees use programs to keep track of the cars for rental.
A Vehicle class that has a VIN (of type string) and gasTank () of type double, properties, a full constructor, and an abstract method called displayDetails() which returns a string.
A Car class that inherits from Vehicle also has a size (of type string) to tell if it is a subcompact, compact, or fullsized car and a full constructor. It should have a method called displayDetails() which returns a string and tells about all of its attributes.
A Truck class that inherits from Vehicle also has a bedSize (of type integer) to how big it is, properties and a full constructor. It should have a method called displayDetails() which returns a string and tells about all of its attributes.
Â
Have correct data types and correct access modifiers (public/private/protected) as well as validation for gasTank and bedSize to prevent negative values in these class definitions.
Create a Car object in main() and a truck object in main() to test your newly created class definitions. Â
Demonstrating Polymorhism for the car rental company. This company rents more than one type of vehicle to customers and the processes for the organization work with cars and trucks at the same time. Demonstrate how to handle this.
Change the test code in main to have an array of 4 Vehicles.
Â
Write a loop that prompts the user 4 times.
The body of the loop should have an If statement asking the user if they are creating a car or a truck. If the user chose a Car it should ask for all of the values for a Car and store one in the next position in the array of vehicles. If it is a truck it should ask for all of the values for a Truck and store one in the next position in the array of vehicles.
After input is complete there should be a polymorphic loop through the array of vehicles that shows the details for all of them to the user with the displayDetails() method.
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I