Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Vehicle Rental System: An OOP Project The Vehicle Rental System is a hands-on project that tests the understanding of object-oriented programming by simulating a real-world

Vehicle Rental System: An OOP Project The "Vehicle Rental System" is a hands-on project that tests the understanding of object-oriented programming by simulating a real-world vehicle rental system. The project includes various classes that embody various elements of the rental system, for example, vehicles, inventories, rental offices, and customers. The objective is to apply the core principles of OOP, such as encapsulation, inheritance, polymorphism, and abstraction, in the development and functionality of the project. Start by creating the Vehicle class, which will encapsulate the concept of a vehicle. This class should have private variables for vehicleID, make, model, year, mileage, type (valid types: Car, SUV, Truck), available (for rent- Boolean- true by default), and daily rate. It should also have appropriate getter and setter methods for each variable. You can validate the type in 2 ways: 1- Write a custom Type setter to validate the vehicles type. Use this setter in the constructor to set the field type instead of direct assignment to avoid instantiating a wrong type vehicle. 2- Use enum similar to assignment 1. Create the Inventory class, which will manage a list of vehicles. This class should have private variables for inventoryID, type (valid types: car, SUV, truck), and a list of vehicles. It should also have a method called addVehicle, which will add a vehicle to the list of vehicles, but only if the type of the vehicle matches the type of the inventory. It should also have a method called removeVehicle, which will remove a vehicle from the list of vehicles. Create the Reportable interface, which will have a method called generateReport() that returns a String. This method will be used to generate a report of the relevant information for the class that implements it. Create the RentalOffice class, which will implement the Reportable interface. This class should have private variables for officeID, locationZip, and a list of inventories. It should also have a list of RentalOrder objects, which will represent the order history of the office. The RentalOffice class should also have methods to add and remove inventories, but it should not allow two inventories of the same type to be added. The generateReport() method for this class should return a string containing the office information, including the list of inventories and vehicles, and the order history of the office. Create the Customer abstract class, which will implement the Reportable interface. This class should have variables for id, name, discountRate, and a list of RentalOrder objects. Also, add the implementations for addOrder, removeOrder, getOrderHistory, and getter methods for the fields. Note that since you are implementing another interface, you have to add its method (generateReport) but cant provide its implementation here, so make it abstract. Also, add a constructor too. Like any other classes in Java, abstract classes can have constructors even when they are only called from their concrete subclasses. Create the Individual and Corporate classes, which inherit the Customer abstract class. The Individual class should have extra variables for age, state, zip, etc. The Corporate class should have extra variables for country, taxID, etc. Both classes should provide implementation for the methods defined in the Customer interface. Make sure to use the super class constructor. Create the RentalOrder class, which will represent a rental transaction. This class should have private variables for totalCost, customer, vehicle, and rentalLength (number of days). It should also have a calculateTotalCost() method, which will calculate the total cost of the rental based on the vehicle rate, customer discount, and number of rental days. It should also have a completeOrder() method, which will add the order to the orderHistory of the customer and the office and make the vehicle unavailable for rent. The RentalOrder class should also have multiple constructors: one that rents a vehicle for one day by default, and another that rents a vehicle for a specified number of days. You use constructor overloading here. Two constructors, one that takes 2 arguments, and the other takes 3 arguments. Make sure to use this keyword in the more generic constructor to invoke the other specific constructor to set the rentalLength default value. Create a Report class which will be used for reporting the information, either by printing in the console or persisting in a CSV file. Therefore, it has two methods that takes an object of type Reportable. Method printToConsole(Reportable reportable) will print the report in the console and persistToCSV(Reportable reportable, String fileName) will print the report to a CSV file. You can use Java built-in libraries such as BufferedWriter or FileWriter OR you may use a 3rd party Java dependencies to work with CSV files. Please ensure that the test class provided below, which includes dummy data and tests the various functionalities of the program, is included in your project and runs without any errors. Your implementation should work seamlessly with this test class and produce the expected output. It is important to closely follow all the requirements and ensure that the Main test class executes without any errors. Any elements not explicitly mentioned in the requirements or not inferable from the Main test class can be designed and implemented at your discretion. Some points to consider: The accuracy of your implementation of all the requirements and the successful execution of the test class against your code will be used to determine your grade for this submission. Start by creating the classes and their variables first, and then move on to the methods and constructors. Pay attention to the relationships between the classes, such as inheritance and composition, and make sure to use the appropriate keywords (extends, implements, etc.) Make sure to follow the rules and constraints specified in the assignment, such as not allowing two inventories of the same type in the RentalOffice class and not allowing vehicles of different types in the Inventory class. Test your code regularly to make sure it is working as expected. Use appropriate variable names and method names to make your code readable and easy to understand. Make use of the interface and abstract classes where necessary to ensure a proper implementation of polymorphism and abstraction. Don't forget to implement the generateReport() method in all classes that require it, and make sure the report is clear and comprehensive. You can use built-in java library StringBuilder to create the nicely formatted string (Search for it) Use the constructors to initialize the object with the required values and also to call the methods that are needed. For the RentalOrder class, make sure to include the calculation of the total cost of the rental and update the availability of the vehicle and the order history of the customer and the office. Remember to submit the work on time and ask for help if you need it.

*PLEASE CODE IN JAVA ONLY. WILL GIVE THUMBS UP*

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions