Class ProjectFlatInfo

java.lang.Object
com.ntu.fdae.group1.bto.models.project.ProjectFlatInfo

public class ProjectFlatInfo extends Object
Represents detailed information about a specific flat type within a BTO project.

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 Details

    • ProjectFlatInfo

      public ProjectFlatInfo(FlatType flatType, int totalUnits, int remainingUnits, double price)
      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 project
      remainingUnits - The number of units still available for application
      price - 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

      public String 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

      public FlatType getFlatType()
      Gets the flat type enum value.
      Returns:
      The flat type