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
-
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
- theCar
being 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:
true
if the rental is available,false
otherwise
-
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
Period
object representing the duration between the start and end dates, ornull
if the rental is available
-
getCar
-
getId
-
getStartDate
-
getEndDate
-