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
ConstructorsConstructorDescriptionRentalManager(Database<Rental> database) Constructs aRentalManagerwith the specified rental database. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a report of all rentals.Gets the rental database.booleanisCarAvailable(Car car, LocalDate startDate, LocalDate endDate) Checks if the specified car is available for rental during the given dates.booleanisCarAvailableNow(Car car) Checks if the specified car is currently available for rental.booleantryRemoveRental(Rental rental) Attempts to remove a rental from the list.booleantryRentCar(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:
trueif the car is available,falseotherwise.
-
isCarAvailableNow
Checks if the specified car is currently available for rental.- Parameters:
car- the car to check.- Returns:
trueif the car is available,falseotherwise.
-
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:
trueif the car was successfully rented,falseotherwise.
-
tryRemoveRental
Attempts to remove a rental from the list.- Parameters:
rental- the rental to remove.- Returns:
trueif the rental was successfully removed,falseotherwise.
-
generateReport
Generates a report of all rentals.- Specified by:
generateReportin interfaceIReportGenerator<RentalReport>- Returns:
- an
ArrayListofRentalReportobjects.
-