Q. Design the following software application as instructed. (6 Marks)
A car rental system helps manage car renting services in which customers rent cars for a given
period, such that a customer can rent one car at a time. System admins should be able to periodically
report about the renting services or inquire about available cars for rent. The system needs to store
information about three things (classes): customer, car, and rent, such that:
–
A Customer class has attributes for id, firstName, lastName, email and phoneNo.
A Car class has attributes for licenseNo, make, model, year, airConditioning, rentPrice,
promotion, availableForRent.
A Rent class has main attributes for rentSN, rentDate and noOfDays.
As a software designer, you are required to draw a class diagram with navigation visibilities, the
data type and visibility of each attribute, as well as the visibility, parameters, and return type of
required methods, while considering the following requirements:
1. The three main classes mentioned above are included.
2. Several types of Cars as subclasses with additional attributes are included:
✓
✓
✓
A SmallCar: fuelType, cylinderSpeed, isConvertable, and isRace
A MediumCar: fuelType, numberOfDoors, trunkSize
A LargeCar: numberOfSeats, wifi
3. Any car object should provide a method to show if the car is currently being rented.
4. The rent price is calculated based on the car type, such that the additional information
of each car type plus the promotion contributes to the rent price.
5. When the promotion value in Car is updated, it will be reflected in car objects of all
subclasses. (Static attribute in Car class)
6. Admins are able to generate reports that show:
a) Number of rented cars of all types during a specific date range (startDate,
endDate). (Static method in Rent class)
b) A list of all available cars with air conditioning at a specific date. (Static method
in Car class ?)
c) A list of all available small race cars at a specific date. (Static method in
SmallCar class)
My comments on each part:
1)
– All attribute should be private
– Add navigation visibilities
– One-to-Many from Customer to Rent
– One-to-One from Rent to Car
2) Sub classes with attributes
3) isAvailableForRent: A method in Car class returns availableForRent. If false, not
available for rent.
4) getRentPrice: A method in each car sub-class that calculates rentPrice (based on
extra attribute) and returns it.
5) promotion in Car class is a static attribute.
6)
a. numberOfRentedCars: A static method in Rent class takes startDate and
endDate and returns number of Rent classes with rentDate falling within the
range.
b. listOfAvailableAirConditionedCars: A static method in Car class that returns an
array of cars with aircondition and availableForRent.
c. listOfAvailableRaceSamllCar: A static method in SmallCar class that returns an
array of cars if isRace and availableForRent.