Question: Problem Description You are to develop and test the Java classes needed to maintain a collection of vehicles of various type. Vehicles should be able

Problem Description You are to develop and test the Java classes needed to maintain a collection of vehicles of various type. Vehicles should be able to be added to the collection; reservations should be able to be made, displayed, and cancelled; and the vehicles should be able to be listed (either all vehicles, or only those that are not reserved). Problem Scenario Vehicles are identified by a unique VIN (Vehicle Identification Number). The set of features maintained for cars, SUVs and trucks are different. Cars are specified as a specific make/model/year, a miles per gallon rating, and seating capacity. SUVs are specified as a particular make/model/year, a miles per gallon rating, seating capacity, and cargo capacity. Trucks are specified as a particular length (in feet), a miles per gallon rating, and load capacity. The list of vehicles that you MUST USE, including the vehicle identification numbers (VINs) provided for this assignment, is given below. (NOTE: Your output is NOT expected to be lined up as shown below. See middle of page 4 below.) Make/Model Mileage Seating Capacity VIN CARS Chevrolet Camaro - 2018 30 mpg 2 HK4GM4564GO Ford Fusion - 2018 34 mpg 4 AB4EG5689GM Ford Fusion Hybrid - 2017 32 mpg 4 KV4EG3245RW Chevrolet Impala - 2019 30 mpg 4 RK3BM4366YH Make/Model Mileage Seating Cargo VIN Capacity Capacity SUVs Honda Odyssey - 2020 28 mpg 7 6 cubic ft. VN9RE2635TD Dodge Caravan - 2019 25 mpg 5 4 cubic ft. QK3FT4273ME Ford Expedition - 2018 20 mpg 5 3 cubic ft. JK2RT8264HY Make/Model Mileage Load VIN Capacity Trucks Ten-Foot 12 mpg 2810 lbs. EJ5KU2437BC Eighteen-Foot 10 mpg 5930 lbs. KG4DM5472RK Twenty-Four-Foot 8 mpg 6500 lbs. EB2WR3082QB Twenty-Four-Foot 8 mpg 6500 lbs. TV3GH4380EK 2 Classes Needed Abstract Vehicle Class instance variables private String description // stores make-model-year for cars and SUVs, stores length for trucks private int mpg // miles per gallon rating private String vin // unique vehicle identification number private Reservation resv // reservation information (a null value means not reserved) constructor Inits with provided description (cars/SUVs: make-model-year, Trucks: length), mpg and VIN. Sets resv to null (i.e., newly created vehicles are not yet reserved). methods public int getMpg() { ... } public String getVIN() { ... } public Reservation getReservation() { ... } public abstract String toString(); // ABSTRACT METHOD must be implemented in each subclass public boolean isReserved() { ... } public void reserve(Reservation r) { ... } public cancelReservation() { ... } - throws UnreservedVehicleException if reservation doesnt exist Car, SUV and Truck Classes Subclasses of the abstract Vehicle class. Each contains an appropriate constructor, added instance variables, and appropriate implementation of the toString method. Reservation Class instance variables private String creditCardNum; // credit card number vehicle reserved under private TimeSpan rentalPeriod; // e.g., four days, two weeks, one month private boolean insuranceSelected; // set to true if optional daily insurance wanted methods appropriate constructor, getter methods and toString method. Note that reservations cannot be altered once created (i.e., Reservation objects are immutable). TimeSpan Class instance variables private char timeUnit; // D (day), W (week), M (month) private int numUnits; // num of days, weeks or months constructor / getters // appropriate constructor and getters Vehicles Class (collection of Vehicle objects) instance variable private Vehicle[ ] agency_vehicles; // array of Vehicle objects (ArrayList type may NOT be used) private int current // used by iterator methods only methods (appropriate constructor) public void add(Vehicle v) // adds a new vehicle to the collection public Vehicle getVehicle(String VIN) // throws VINNotFoundException if no vehicle found for provided VIN iterator methods public void reset() // resets to first vehicle in list public boolean hasNext() // returns true if more vehicles in list to retrieve pubic Vehicle getNext() // returns next vehicle in list 3 UML Class Diagram Aggregation (collection) Composition Subclass 4 The following summarizes the requirements for this stage of the program: 1. Initially populate the collection of vehicles with the information on page 1. (USEFUL HINT: Use your own simple VINs for your testing, and add the actual VINs before submitting) 2. Can add new vehicles to the collection. 3. Can reserve a vehicle, display a reservation, and cancel a reservation. 4. Can display the list of all vehicles, e.g., ALL AGENCY VEHICLES Ford Fusion - 2018 (Car) MPG: 34 Seating: 4 VIN: AB4EG5689GM Dodge Caravan - 2019 (SUV) MPG: 25 Seating: 5 Storage: 4 cu. ft. VIN: QK3FT4273ME Eighteen-Foot (Truck) MPG: 10 Load Capacity: 5930 lbs. VIN: KG4DM5472RK etc. 5. Can display a list of unreserved vehicles only. AVAILABLE VEHICLES Dodge Caravan - 2019 (SUV) MPG: 25 Seating: 5 Storage: 4 cu. ft. VIN: QK3FT4273ME Eiighteen-Foot (Truck) MPG: 10 Load Capacity: 5930 lbs. VIN: KG4DM5472RK etc. Main Class The main class of the program (with main method) will behave as a test driver for the classes developed. The program must provide the following menu of options EXACTLY as given: 1 - Display all vehicles 2 - Display available vehicles 3 - Reserve a vehicle 4 - Display a Reservation 5 - Cancel a Reservation 6 - Add a vehicle 7 - Quit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!