Package crms.lib
Class RentalManager
java.lang.Object
crms.lib.RentalManager
- All Implemented Interfaces:
IReportGenerator<RentalReport>
Manages car rentals.
This class provides functionalities to check car availability, rent cars, remove rentals, and generate rental reports.
-
Constructor Summary
ConstructorDescriptionRentalManager
(Database<Rental> database) Constructs aRentalManager
with the specified rental database. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a report of all rentals.Gets the rental database.boolean
isCarAvailable
(Car car, LocalDate startDate, LocalDate endDate) Checks if the specified car is available for rental during the given dates.boolean
isCarAvailableNow
(Car car) Checks if the specified car is currently available for rental.boolean
tryRemoveRental
(Rental rental) Attempts to remove a rental from the list.boolean
tryRentCar
(Car car, LocalDate startDate, LocalDate endDate) Attempts to rent a car for the specified period.
-
Constructor Details
-
RentalManager
-
-
Method Details
-
getDatabase
-
isCarAvailable
Checks if the specified car is available for rental during the given dates.- Parameters:
car
- the car to check.startDate
- the start date of the rental period.endDate
- the end date of the rental period.- Returns:
true
if the car is available,false
otherwise.
-
isCarAvailableNow
Checks if the specified car is currently available for rental.- Parameters:
car
- the car to check.- Returns:
true
if the car is available,false
otherwise.
-
tryRentCar
Attempts to rent a car for the specified period.- Parameters:
car
- the car to rent.startDate
- the start date of the rental period.endDate
- the end date of the rental period.- Returns:
true
if the car was successfully rented,false
otherwise.
-
tryRemoveRental
Attempts to remove a rental from the list.- Parameters:
rental
- the rental to remove.- Returns:
true
if the rental was successfully removed,false
otherwise.
-
generateReport
Generates a report of all rentals.- Specified by:
generateReport
in interfaceIReportGenerator<RentalReport>
- Returns:
- an
ArrayList
ofRentalReport
objects.
-