Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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).

Use the following methods and classes described above.

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 Il 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 is Reserved() {...} public void reserve (Reservation r) { ... } public cancelReservation() { ... } - throws UnreservedVehicleException if reservation doesn't 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 Time Span rentalPeriod; Il e.g., four days, two weeks, one month private boolean insurance Selected; // set to true if optional daily insurance wanted methods appropriate constructor, getter methods and to String 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; Il num of days, weeks or months constructor / getters Il appropriate constructor and getters Vehicles Class (collection of Vehicle objects) instance variable private Vehicle[ ] agency_vehicles; Il 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) Il 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() Il returns true if more vehicles in list to retrieve pubic Vehicle getNext() // returns next vehicle in list 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 Eighteen-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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

Students also viewed these Databases questions

Question

What is Aufbau's rule explain with example?

Answered: 1 week ago

Question

Write Hund's rule?

Answered: 1 week ago