Package crms.lib
Class CarManager
java.lang.Object
crms.lib.CarManager
- All Implemented Interfaces:
IReportGenerator<CarReport>
Manages car inventory and rentals.
This class provides functionalities to add and remove cars from inventory, check car availability, and generate reports about the cars.
-
Constructor Summary
ConstructorDescriptionCarManager
(Database<Car> carDatabase, Database<Rental> rentalDatabase) Constructs aCarManager
with the specified car and rental databases. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a report that shows the properties and availability of eachCar
object.Gets the car database.boolean
isCarAvailableNow
(Car car) Checks if the specified car is currently available for rental.boolean
Adds aCar
to the inventory if its ID is unique.boolean
tryRemoveCar
(Car car) Removes aCar
from the inventory based on its unique ID.
-
Constructor Details
-
CarManager
-
-
Method Details
-
getDatabase
-
tryAddCar
Adds aCar
to the inventory if its ID is unique.- Parameters:
car
- TheCar
object to be added.- Returns:
- True if the car was added successfully, false otherwise.
-
tryRemoveCar
Removes aCar
from the inventory based on its unique ID.- Parameters:
car
- TheCar
object to be removed- Returns:
- true if the car was removed successfully, false otherwise.
-
generateReport
Generates a report that shows the properties and availability of eachCar
object.- Specified by:
generateReport
in interfaceIReportGenerator<CarReport>
- Returns:
- an
ArrayList
ofCarReport
objects.
-
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.
-