Package crms.lib
Class Rental
java.lang.Object
crms.lib.Rental
Represents a rental transaction for a
Car.
This class contains information about the rental period, the car being rented, and a unique rental ID.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Rental
Creates a new Rental object with the specified properties.The rental ID is generated based on a preset format: "1" + start date (MMDDYY) + car ID.
- Parameters:
car- theCarbeing rentedstart- the start date of the rental periodend- the end date of the rental period
-
-
Method Details
-
isAvailable
public boolean isAvailable()Checks if the rental is available.A rental is considered available if the start date is
null.- Returns:
trueif the rental is available,falseotherwise
-
getRentalPeriod
Calculates the rental period.The rental period is the duration between the start date and the end date. If the rental is available (start date is
null), this method returnsnull.- Returns:
- a
Periodobject representing the duration between the start and end dates, ornullif the rental is available
-
getCar
-
getId
-
getStartDate
-
getEndDate
-