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
ConstructorsConstructorDescriptionCarManager(Database<Car> carDatabase, Database<Rental> rentalDatabase) Constructs aCarManagerwith the specified car and rental databases. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a report that shows the properties and availability of eachCarobject.Gets the car database.booleanisCarAvailableNow(Car car) Checks if the specified car is currently available for rental.booleanAdds aCarto the inventory if its ID is unique.booleantryRemoveCar(Car car) Removes aCarfrom the inventory based on its unique ID.
-
Constructor Details
-
CarManager
-
-
Method Details
-
getDatabase
-
tryAddCar
Adds aCarto the inventory if its ID is unique.- Parameters:
car- TheCarobject to be added.- Returns:
- True if the car was added successfully, false otherwise.
-
tryRemoveCar
Removes aCarfrom the inventory based on its unique ID.- Parameters:
car- TheCarobject to be removed- Returns:
- true if the car was removed successfully, false otherwise.
-
generateReport
Generates a report that shows the properties and availability of eachCarobject.- Specified by:
generateReportin interfaceIReportGenerator<CarReport>- Returns:
- an
ArrayListofCarReportobjects.
-
isCarAvailableNow
Checks if the specified car is currently available for rental.- Parameters:
car- the car to check.- Returns:
trueif the car is available,falseotherwise.
-