Class ProjectFlatInfo
This class models the characteristics of a particular flat type available in a project, including its type (e.g., 3-room, 4-room), inventory information, and pricing. It provides methods to track and update the availability of units as applications are processed and approved.
The class manages the total and remaining units of a specific flat type, ensuring that inventory is correctly adjusted during the application and booking processes.
-
Constructor Summary
ConstructorsConstructorDescriptionProjectFlatInfo
(FlatType flatType, int totalUnits, int remainingUnits, double price) Constructs a new ProjectFlatInfo with the specified details. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Decreases the number of remaining units by one, simulating a flat being reserved.Gets the flat type enum value.double
getPrice()
Gets the price of this flat type.int
Gets the number of units of this flat type that are still available for application.int
Gets the total number of units of this flat type in the project.Gets the name of this flat type as a string.void
Increases the number of remaining units by one, simulating a flat being released.
-
Constructor Details
-
ProjectFlatInfo
Constructs a new ProjectFlatInfo with the specified details.- Parameters:
flatType
- The type of flat (e.g., 2-ROOM, 3-ROOM)totalUnits
- The total number of units of this flat type in the projectremainingUnits
- The number of units still available for applicationprice
- The price of this flat type in Singapore dollars
-
-
Method Details
-
decreaseRemainingUnits
public boolean decreaseRemainingUnits()Decreases the number of remaining units by one, simulating a flat being reserved.This method is typically called when an application is approved, reducing the available inventory. It prevents the remaining units count from going below zero.
- Returns:
- true if a unit was successfully reserved, false if no units were available
-
increaseRemainingUnits
public void increaseRemainingUnits()Increases the number of remaining units by one, simulating a flat being released.This method is typically called when an application is withdrawn or cancelled, returning a previously reserved unit to the available inventory.
-
getTypeName
Gets the name of this flat type as a string.- Returns:
- The string representation of the flat type
-
getTotalUnits
public int getTotalUnits()Gets the total number of units of this flat type in the project.- Returns:
- The total number of units
-
getRemainingUnits
public int getRemainingUnits()Gets the number of units of this flat type that are still available for application.- Returns:
- The number of remaining units
-
getPrice
public double getPrice()Gets the price of this flat type.- Returns:
- The price in Singapore dollars
-
getFlatType
Gets the flat type enum value.- Returns:
- The flat type
-