Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java, design a rental car program, where the user is can look at the available cars at the rental agency and make a reservation

In java, design a rental car program, where the user is can look at the available cars at the rental agency and make a reservation for the car of their choice.

Key Points:

  • Each car will be identified by its VIN
  • There are three types of vehicles that can be rented, which are:
    • Car:
      • Must show brand, model, and year, mpg rating, number of seating
    • SUV:
      • Must show brand, model, and year, mpg rating, number of seating, cargo capacity
    • Truck:
      • Must show the length (in feet), mpg rating, and load capacity (lbs.)
  • The program should be able to do the following:
    • Populate the collection of vehicles
    • Add vehicles to collection
    • Reserve a vehicle
    • Display reservation
    • Cancel reservation
    • Display all vehicles
    • Display non-reserved vehicles

The following classes should be utilized:

  • Vehicle Class
    • Must be Abstract
    • Contains the following 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)
    • A constructor that does the following:
      • Inits with provided description, mpg, VIN
      • Sets resv to null (i.e., newly created vehicles are not yet reserved).
    • Contains the following 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
  • A class for each type of vehicle (car, suv, and truck)
    • Exist as subclasses of the vehicle class and contains constructor, variables, and toString method

  • Reservation Class
    • Contains the following 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
    • Contains the following methods:
      • getters
      • setters
      • constructor
      • toString

  • Timespan Class
    • Contains the following variables:
      • private char timeUnit; // D (day), W (week), M (month)
      • private int numUnits; // num of days, weeks or months
    • Includes constructor and getters

  • Vehicles Class
    • Contains the following variables:
      • private Vehicle[ ] agency_vehicles; // array of Vehicle objects (ArrayList type may NOT be used)
      • private int current // used by iterator methods only
    • Contains the following methods:
      • 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
    • Contains the following 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

  • Main Class
    • Prompts user with the following menu:
      • 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

Step: 3

blur-text-image

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions