You are to develop a Java program, using an object-oriented design, capable of maintaining vehicle rental reservations f

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

You are to develop a Java program, using an object-oriented design, capable of maintaining vehicle rental reservations f

Post by answerhappygod »

You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 1
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 1 (79.01 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 2
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 2 (16.05 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 3
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 3 (76.65 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 4
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 4 (48.63 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 5
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 5 (69.64 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 6
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 6 (74.79 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 7
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 7 (45.25 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 8
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 8 (58.43 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 9
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 9 (77.48 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 10
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 10 (67.4 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 11
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 11 (30.82 KiB) Viewed 67 times
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 12
You Are To Develop A Java Program Using An Object Oriented Design Capable Of Maintaining Vehicle Rental Reservations F 12 (49.72 KiB) Viewed 67 times
You are to develop a Java program, using an object-oriented design, capable of maintaining vehicle rental reservations for a vehicle rental agency that rents cars, SUVs and trucks to corporate customers. Problem Scenario The agency offers various model cars, SUVs and trucks for rent to corporate customers (not private individuals). Vehicles may be rented for a period of days, weeks, or months. Monthly rentals are cheaper (on a daily basis) than weekly rentals, and weekly rentals are cheaper than daily rentals. There is also a mileage charge and optional daily insurance. Rates differ for cars, SUVs and trucks. (There is no difference in the rates among various model vehicles however.) Each corporate customer may choose to be a "Prime Corporate Customer" for a yearly fee. Prime customers receive 100 free miles for each individual rental Users of the System There are two types of users of the system, Employees and Managers, described below. Employees of the rental agency may do the following (referred to as use cases in software development): (1) view.current rates (for a given vehicle type, including insurance rates and per mile charge), (2) view available (unreserved) vehicles (cars, SUVs or trucks), (3) display estimated cost (for a given vehicle type, expected rental period, expected number of miles to be driven, insurance option, and if a prime customer), (4) reserve a vehicle (by credit card number) for a specific vehicle, rental period, and daily insurance option (accept or decline), (5) cancel a reservation (by provided credit card number) (6) view a specific corporate account (by credit card number) and (7) process a returned vehicle (by provided VIN) which: (a) calculates charge based on rates at the time reserved, number of days had the vehicle, the number of miles driven, whether daily insurance was selected, and whether a Prime customer (Prime customers get 100 free miles) (b) removes the reservation for the returned vehicle (C) creates/stores a transaction entry. Managers of the vehicle rental agency may: (1) view/update current rates (including per mile charge and daily insurance rates), (2) view all vehicles (each indicated as reserved or unreserved), (3) add corporate accounts, (4) view a list of all current reservations, (5) view a list of all accounts, and (6) view a list of all transactions (i.e, history of returned and paid rentals).

Vehicle Information 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 and model, a miles per gallon rating, and seating capacity, SUVs are specified as a particular make and model, a miles per gallon rating, seating capacity, and cargo capacity. Trucks are specified as a particular length (in feet), miles per gallon rating, and load capacity.

1. The program must be able to maintain a collection of specific model vehicles of type Car, SUV, and Truck, and be able to display the vehicles in the following format: Ford Fusion (Car) MPG:34 Seating: 4 VIN: AB4EG5689GM Honda Odyssey (SUV) MPG: 28 Seating: 7 Storage: 6 cu.ft. VIN: QK3FT4273NE Chevrolet Impala (Car) MPG: 30 Seating: 4 VIN: RK3MB3366YH Eighteen-Foot (Truck) MPG: 12 Load Capacity: 5390 lbs. VIN: KG4MD5372RK 2. The program must be able to maintain a set of current rates for Cars, SUVs and Trucks, and display the rates in the following format, that can be updated when needed: Car Rates Daily: $24.95 Weekly: $169.95 Monthly: $514.95 Per Mile: $0.16. Daily Insur: $14.95 3. The program must be able to provide an estimated cost of rental based on the vehicle type, expected rental period, expected number of miles to be driven, insurance option, and whether a Prime Customer. 4. The program must allow vehicles to be reserved by a specific account customer, for a specific VIN, time period, and daily insurance option. 5. The program must allow reservations to be cancelled (by a provided credit card number). 6. The program must process a returned vehicle to (a) display the amount due for the actual number of days had and mileage driven (with 100 free miles for Prime Customers), (b) move the reservation information to the transaction "file" (Transactions object), and (c) remove the reservation for the given vehicle to calculate the cost, the weekly or monthly rate will be applied, when applicable, with any left-over days pro-rated at the weekly or daily rate (e.g., 40 days would be 31 days at the monthly rate, and the remaining 9 days each at a rate of (monthly rate/31). 7. The program must be able to display all reservations 8. The program must allow comorate customer accounts to be created, storing the company name, whether they are a prime customer and credit card number. 9. The program must be able to display specific accounts (by credit card number) and also a list of all corporate accounts 10. The program must maintain a history of all completed transactions (i.e, when a vehicle is returned and paid for). The information stored should include the name of the company, the company's credit card number, the type and model of vehicle rented, the number of days had, the number of miles driven, and the total cost displayed as follows:

public interface Userinterface { import java.util.Scanner // the start method simply begins the command loop ll of the corresponding user interface type (employee or manager) public void start(Scanner input): ) public class EmployeeUl implements Userinterface Il no constructor needed, calls static methods of the Systeminterface 1 starts a command loop" that repeatedly: (a) displays a menu of options, (b) gets the selected Il option from the user, and (c) executes the corresponding command. private boolean quit = false; public void start (Scanner input) { int selection: Il command loop while(!quit) { displayMenu(): selection = getSelection (input): execute(selection, input): > private void execute(int selection, Scanner input) int veh_type; String vin creditcard_num: Stringi display_lines, Rental Details rental_details: Reservation_Details reserv_details: switch(selection) { Il display rental rates case 1: veh_type = getVehicleType(input): switch(veh_type case 1: display_lines = Systeminterface.getCarRates(); break; case 2: display_lines = Systeminterface.getSUVRates(): break case 3: display_lines = Systeminterface.getTruckRates(); break; display Results(display_lines): break // display available vehicles case 2: veh_type = getVehicle Type(input) switchveh_typeX case 1: display_lines = Systeminterface.getAvailCars(); break; case 2: display_lines = Systeminterface getAvailSUVs(); break; case 3: display_lines = Systeminterface.getAvail Trucks(); break; } displayResults(display_lines): break; Il display estimated rental cost case 3. rental_details = getRentalDetails(input); display_lines = Systeminterface estimatedRentalCost(rental_details) displayResults(display_lines): break

// make a reservation case 4: reserv_details = getReservation Details(input); display_lines = Systeminterface.makeReservation(reserv_details); displayResults(display_lines); break; Il cancel a reservation case 5: vin = getVIN(user_input): display_lines = Systeminterface.cancelReservation(creditcard_num, vin); display Results(display_lines): break; Il view corporate account and company reservations) case 6: creditcard_num = getCredit CardNum(input): display_lines = Systeminterface.getAccount(creditcard_num); displayResults(display_lines); break; Il process returned vehicle case 7: creditcard_num= getCredit CardNum(user_input): vin = getVIN(input): display_lines = Systeminterface.processRetumedVehicle(vin, num_day_used, num_miles_driven) displayResults(display_lines): break; // quit program case 8: quit = true; ) 11 ------ private methods private void displayMenu() { } // displays the menu of options private int getSelection(Scanner input) { } 1/ prompts user for selection from menu (continues to prompt is selection < 1 or selection > 8) private String getVIN(Scanner input) 1/ prompts user to enter VIN for a given vehicle (does not do any error checking on the input) { } private int getVehicleType(Scanner input) // prompts user to enter 1, 2 or 3, and returns (continues to prompt user if invalid input given) { } private Rental Details getRentalDetails(Scanner input) 1/ prompts user to enter required information for an estimated rental cost (vehicle type, estimated Il number of miles expected to be driven, rental period (number of days, weeks or months), and // insurance option, returning the result packaged as a Rental Details object (to be passed in method Il calls to the System Interface) { } private Reservation Details getReservation Details(Scanner input) 1/ prompts user to enter required information for making a reservation (VIN of vehicle to reserve, // credit card num, rental period, and insurance option), returning the result packaged as a // Reservation Details object (to be passed in method calls to the Systeminterface) { } private void display Results(String lines) il displays the array of strings passed, one string per screen line { }

public class Systeminterface private static CurrentRates agency_rates; private static Vehicles agency_vehicles: private static Accounts accounts: private static Transactions transactions_history: // used to init static variables (in place of a constructor) public static void initSystem(CurrentRates r, Vehicles v. Accounts a, Transactions t) { agency rates ar agency_vehicles = v: accounts = a; transactions_history at > // Note that methods make Reservation, cancelReservation, addAccount, and updateXXXRates return Il an acknowledgement of successful completion of the requested action (e.g. "Vehicle QK3FL4273ME Il successfully reserved"). Method processReturned Vehicle returns the final cost for the returned Il vehicle (e.g. "Total charge for VIN OK3FL4273ME for 3 days, 233 miles @ 0.15/mile and daily // insurance @ 14.95/day (with 100 miles credit as Prime customer) = $xxx.xx.) // Current Rates Related Methods public static String[] getCarRates() {...} public static String] getSUVRates() {...} public static Stringl 1 getTruckRates() {...} public static String[] updateCarRates (VehicleRates r) {...} public static String] updateSUVRates(VehicleRates ) { public static StringupdateTruckRates(VehicleRates ) {...) public static Stringt estimated RentalCost(Rental Details details) (..) public static String processReturnedVehicle(String vin, int num_days_used, int num_miles_driven) {...} // Note that the rates to be used are retrieved from the VehicleRates object stored in the specific rented // vehicle object, the daily insurance option is retrieved from the Reservation object of the rented // vehicle, and whether they are a Prime customer is retrived from the Customer Account object vehicle // associated with the Reservation object associated with the specific rented vehicle. // Vehicle Related Methods public static Stringt getAvailCars() {...} public static Stringt getAvailSUVs() {...} public static String] getAvailTrucks() {...) public static Stringſ getAll Vehicles() {...} public static String[] makeReservation(Reservation Details details) {...} public static String[] cancelReservation(String vin) {...} public static Stringl 1 getReservation(String vin) {...) public static String 1 getAllReservations() {...} 1/ Customer Accounts Related Methods public static String[] addAccount(String creditcard, String company_name, boolean prime_cust) { ...) public static Stringt getAccount(String creditcard_num) {...) public static Stringt I getAllAccounts(){...} 1/ transactions-related methods public static Stringl getAllTransactions() {...} }

public class AgencyRental Program! public static void main(String[] args) { // Provide Hard-coded Current Agency Rates CurrentRates agency_rates = new CurrentRates(new CarRates(XX.XX.XX.XX.XX), new SUVRates(xx.xx.xx.xx.xx). new TruckRates(xx, xx.xx.xx.xx)); Create an Initially Empty Vehicles Collection, and P Populate Vehicles agency_vehicles = new Vehicles(): populate(agency_vehicles): 1/ supporting private static method to be added) // Create Initially Empty Accounts and Transactions Objects Accounts accounts = new Accounts(): Transactions transactions = new Transactions(); // Establish User Interface Scanner input = new Scanner(System.in); Userinterface ui; boolean quit = false; // Create Requested UI and Begin Execution while(!quit){ // (allows switching between Employee and Manager user interfaces while running) ul = getUl(input); if(uis null) quit = true; else { l Init System Interface with Agency Data (if not already initialized) if(ISysteminterface.initialized()) Systeminterface.initSystem(agency_rates, agency_vehicles, accounts, transactions) // Start User Interface ul.start(input): 1 public static Userinterface getul (Scanner input) { boolean valid_selection = false; while(valid_selection) { System.out.print("1 - Employee, 2 - Manager, 3 - quit: "); selection input.nextInt(); if(selection == 1) { return new Employee Interface(): valid_selection = true; else if(selection == 2)x return new Managerinterface(): valid_selection = true; else if(selection == 3){ return null; valid_selection = true; > else System.out.println("Invalid selection - please reenter"); } return ui:

Abstract Vehicle Class instance variables private String description // make-model for cars/suvs, length for trucks private int mpg Il miles per gallon private String vin // unique vehicle identification number private Reservation resv // If null, then vehicle not reserved private VehicleRates rates; II only assigned when vehicle reserved constructor public Vehicle(String description, int mpg, String vin) { this.description = description: this.mpg = mpg: this.vin = vin resv = null; il init as "no reservation" rates = null; // used to hold rates at the time of the reservation ) methods public String getDescription() {....) public int getMpg((...) public String getVINO (...) public Reservation getReservation(){...} public VehicleRates getQuoted Rates() {...} public boolean is Reserved() (...) public void setReservation Reservation) (...)-throws Reserved VehicleException (if vehicle reserved) public void setQuotedRates(VehicleRates cost) {...) public cancelReservation() {...)-throws UnreservedVehicleException if reservation doesn't exist public abstract String toString(); // ABSTRACT METHOD - implemented in each subclass Abstract VehicleRates Class Subclasses CarRates, SUVRates, TruckRates will be constructed with a specific set of rates. instance variables (for storing daily, Weekly, and monthly rates, mileage charge, and daily insurance rate. constructor public VehicleRates (double daily_rate, double weekly_rate, double monthly_rate, double mileage_chrg. double daily_insur_rate) methods public double getDailyRate(): Il cost per day public double getWeekly Rate(); Il cost per week public double getMonthly Rate(); Il cost per month public double getMileageChrgo: 1/ cost per mile, based on vehicle type public double getDailyInsurRate(); // insurance cost (per day) public abstract String toString(): Il forces subclasses to provde an appropriate toString method

a Car, SUV and Truck Classes Contain a constructor, possible instance variables, and appropriate implementation of the toString method. Reservation Class instance variables private String companyName private String credit CardNum: // credit card number on file for company account private TimeSpan rentalPeriod: Il e.g., TimeSpan type stores, e.g. 3. 'D' (3 days) private boolean insurance Selected: ll set to true if optional daily insurance wanted methods appropriate constructor, getter and toString methods. Note that reservations cannot be altered once created (i.e., Reservation objects are immutable). CarRates, SUVRates and TruckRates Classes Only need to contain a constructor, and appropriate implementation of the abstract methods of the VehicleRates class (each returning a hard-coded set of rates). RentalDetails Class A Rental Details class contains the information related to a given vehicle rental for the sake of computing the rental charges - vehicle type, rental period, estimated number of miles to be driven, insurance option, and whether a prime customer. There are no objects of type Rental Details stored anywhere in the program (and thus not part of the UML class diagram). These objects are only used for passing information between methods. Thus, these classes contain only a constructor and getter methods, and are not stored anywhere in the system. Reservation Details Class Contains the information for making a reservation (VIN, creditcard_num, rental period, daily insurance option). Only used to pass this reservation information from the user interface to the system interface. Thus, these classes contain only a constructor and getter methods, and are not stored anywhere in the system. Account Class Transaction Class instance variables instance variables private String creditcard_num; private String creditcard_num: private String company name; private String company name: private boolean prime_customer private String vehicle_type; // car, SUV or Truck methods private String rental_period; 1 days, week, months (appropriate constructor) private String miles driven; private String rental_cost; public String getCreditCardNum() {...} public boolean prime Customer() {...} methods public String toString() {..) (appropriate constructor) public String toString() {...}

= CurrentRates Class (aggregation of VehicleRate objects) instance variable private VehicleRates[] rates = new Vehicle Rates[3]; // array of size 3 to store rates for three types of vehicles methods constructor - passed CarRates, SUVRates and Truck Rates objects to assign in rates array. public VehicleRates getCarRates() {...} public void setCarRates(VehicleRates rX ...) public VehicleRates getSUVRates() {...} public void setSUVRates(VehicleRates ) ...) public VehicleRates getTruck Rates() {...} public void setTruckRates(VehicleRates rX ...) public double calcEstimated Cost(int vehicleType, TimeSpan estimated RentalPeriod, int estimatedNum Miles, boolean dailyInsur, boolean prime Customer) {...} - called to calculate a cost quote for a customer given an estimated number of days will use and estimated number of miles will drive, whether the daily insurance wanted, and whether a prime customer or not. - uses the CURRENT standard rates for the vehicle type (car, SUV or truck) public double calcActualCost(VehicleRates rates, int numDaysused, int NumMiles Driven boolean dailylnsur, boolean primeCustomer) {...} - called to calculate charge of a returned rented vehicle (for number of days used, num miles driven, whether daily insurance was selected, and whether a prime customer or not). - uses the QUOTED RATE, the rates as they were at the time of the reservation - if the number of days is less than 7. then charged the daily rate: If number of days is greater than 7 and less than 30, then charged the weekly rate with remaining days a prorated weekly rate); otherwise, get the monthly rate (with remaining days a prorated monthly rate). Vehicles Class (aggregation of Vehicle objects) instance variables private VehicleNode headlinked list of Vehicle objects private VehicleNode current; // index of current vehicle used by terator methods methods (appropriate constructor) public void add(Vehicle v) public Vehicle getVehicle(VIN) throws VINNotFoundException if no vehicle found for provided VIN iterator methods public void reset() Il 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

Accounts Class (aggregation of Account objects) instance variable private AccountNode accounts; // linked list of Account objects (Java ArrayList type may also be used) methods (appropriate constructor) public void add(Account acct) {...} public Account getAccount(String creditcard_num) {...} // returns the account object with credit card -throws InvalidCredit CardException if credit card entered not 16 digits (with no non-digit chars) - throws AccountNotFoundException if credit card number does not exist for any customer account iterator methods (similar to Vehicles class) Transactions Class (aggregation of Transaction objects) instance variable private Transaction[ ] transactions: array of Transaction objects (Java ArrayList type may also be used) methods (appropriate constructor) public void add(Transaction tran) {...} iterator methods (similar to Vehicles class)

System Interface Methods (to implement and test): 1/ rates-related System Interface methods public static String[] getCarRates() {...} public static String[] getSUVRates() {...} public static String[] getTruckRates() {...} public static String[] updateCarRates() {...) public static String[] updateSUV Rates() {...) public static String update Truck Rates() { } public static Stringt estimated RentalCost(RentalDetails details) {...} public static String process Returned Vehicle(String vin, int num_days_had, int num_miles_driven) {...} Il vehicle-related System Interface methods public static Stringt I getAvailCars() {...} returns vehicles not reserved public static Stringl 1 getAvailSUVS({...} public static Stringl 1 getAvailTrucks() { } public static String( 1 getAllVehicles() {...} // returns all vehicles (both reserved and unreserved) // reservation-related methods public static String[] makeReservation(Reservation Details details) {...} public static String[] cancelReservation(String vin) (...) public static String[] getReservation(String vin) {...} public static String[] getAllReservations() {...} // customer accounts-related System Interface methods public static String[] addAccount(String creditcard_num, String company_name, boolean prime_cust) {...} public static String] getAccount(String creditcard_num) {...} public static Stringl 1 getAllAccounts() {...} // transactions-related System Interface methods public static Stringt addTransaction(String creditcard_num, String company_name, int vehicle_type. String rental_period, String rental_cost) {...} public static String[] getAllTransactions() {...)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply