Class BTOProject

Object
CSVDecodable
BTOProject
All Implemented Interfaces:
CSVEncodable

public class BTOProject extends CSVDecodable implements CSVEncodable
A class representing BTO Project containing information for the project and has functions to modify the project information and handle users' applications to the project.
Author:
Ryu Hyungjoon
  • Field Details

    • projectName

      private String projectName
      name of project
    • neighborhood

      private String neighborhood
      neighbourhood which project belong to
    • flats

      private EnumMap<FlatType,FlatInfo> flats
      flat info, based on flat type
    • openingDate

      private LocalDate openingDate
      Opening date of project
    • closingDate

      private LocalDate closingDate
      closing date of project
    • managerName

      private String managerName
      temporary value for decoding and linking purposes.
    • managerInCharge

      private HDBManager managerInCharge
      the manager in charge of this project
    • totalOfficerSlots

      private int totalOfficerSlots
      slots of project, for project. does not decrement
    • officerNames

      private List<String> officerNames
      temporary value for decoding and linking purposes.
    • officers

      private List<HDBOfficer> officers
      officers of this project
    • visibility

      private boolean visibility
      whether this is pubically visible
    • pendingOfficerNames

      private List<String> pendingOfficerNames
      temporary value for decoding and linking purposes.
    • pendingOfficers

      private List<HDBOfficer> pendingOfficers
      Officers that are pending approval
    • MAX_OFFICER_NUM

      private static int MAX_OFFICER_NUM
      Number of officers at max
  • Constructor Details

    • BTOProject

      public BTOProject(List<CSVCell> cells) throws Exception
      Throws:
      Exception
    • BTOProject

      public BTOProject(String projectName, String neighborhood, int maxTwoRoomUnits, int maxThreeRoomUnits, int twoRoomPrice, int threeRoomPrice, LocalDate openingDate, LocalDate closingDate, HDBManager managerInCharge, int totalOfficerSlots) throws Exception
      Constructor for BTOProject class when manager creates a new BTOProject.
      Parameters:
      projectName - Name of the project.
      neighborhood - Neighborhood of the project.
      maxTwoRoomUnits - Maximum number of two room units in the project.
      maxThreeRoomUnits - Maximum number of three room units in the project.
      twoRoomPrice - Price of two room units in the project.
      threeRoomPrice - Price of three room units in the project.
      openingDate - Opening date of the project.
      closingDate - Closing date of the project.
      managerInCharge - Manager in charge of the project.
      totalOfficerSlots - Total number of officer slots available for the project.
      Throws:
      Exception - if any of the input values are invalid
  • Method Details

    • retrieveConnectedUsers

      public void retrieveConnectedUsers(ArrayList<HDBOfficer> officers, ArrayList<HDBManager> managers)
      Retrieve the connected officers and manager as an object for this project by comparing the names the project has.
      Parameters:
      officers - List of officer objects
      managers - List of manager objects
    • containsUnitsThatFitsPriceRange

      public boolean containsUnitsThatFitsPriceRange(int min, int max)
    • getProjectName

      public String getProjectName()
      Get the project name of the BTO project.
      Returns:
      the project name of the BTO project.
    • setProjectName

      public void setProjectName(String name)
      Set the project name of the BTO project.
      Parameters:
      name - the new project name of the BTO project.
    • getNeighborhood

      public String getNeighborhood()
      Get the neighborhood of the BTO project.
      Returns:
      the neighborhood of the BTO project.
    • setNeighborhood

      public void setNeighborhood(String neighborhood)
      Set the neighborhood of the BTO project.
      Parameters:
      neighborhood - the new neighborhood of the BTO project.
    • getApplicableFlats

      public List<FlatInfo> getApplicableFlats(Set<FlatType> applicableTypes)
      Get the applicable flat information for specific flat types.
      Parameters:
      applicableTypes - Set of flat types to get applicable flats for.
      Returns:
      List of FlatInfo objects representing the applicable flats for the given flat types.
    • getFlatForType

      public FlatInfo getFlatForType(FlatType type)
      Get the flat information for a specific flat type.
      Parameters:
      type - The flat type to get information for.
      Returns:
      The FlatInfo object representing the flat information for the given flat type.
    • setTwoRoomUnits

      public void setTwoRoomUnits(int twoRoomUnits) throws IllegalArgumentException
      Set the number of two room units available in the project.
      Parameters:
      twoRoomUnits - Number of two room units to set.
      Throws:
      IllegalArgumentException - if the number of two room units is negative.
    • setThreeRoomUnits

      public void setThreeRoomUnits(int threeRoomUnits) throws IllegalArgumentException
      Set the number of three room units available in the project.
      Parameters:
      threeRoomUnits - Number of three room units to set.
      Throws:
      IllegalArgumentException - if the number of three room units is negative.
    • getTwoRoomUnits

      public int getTwoRoomUnits()
      Get the number of two room units available in the project.
      Returns:
      Number of two room units available in the project.
    • getThreeRoomUnits

      public int getThreeRoomUnits()
      Get the number of three room units available in the project.
      Returns:
      Number of three room units available in the project.
    • setTwoRoomPrice

      public void setTwoRoomPrice(int twoRoomPrice) throws IllegalArgumentException
      Set the price of two room units in the project.
      Parameters:
      twoRoomPrice - Price of two room units to set.
      Throws:
      IllegalArgumentException - if the price is negative.
    • setThreeRoomPrice

      public void setThreeRoomPrice(int threeRoomPrice) throws IllegalArgumentException
      Set the price of three room units in the project.
      Parameters:
      threeRoomPrice - Price of three room units to set.
      Throws:
      IllegalArgumentException - if the price is negative.
    • getTwoRoomPrice

      public int getTwoRoomPrice()
      Get the price of two room units in the project.
      Returns:
      Price of two room units in the project.
    • getThreeRoomPrice

      public int getThreeRoomPrice()
      Get the price of three room units in the project.
      Returns:
      Price of three room units in the project.
    • getOpeningDate

      public LocalDate getOpeningDate()
      Get the opening date of the project.
      Returns:
      The opening date of the project.
    • getClosingDate

      public LocalDate getClosingDate()
      Get the closing date of the project.
      Returns:
      The closing date of the project.
    • getStringOpeningDate

      public String getStringOpeningDate()
      Get the opening date as a string.
      Returns:
      The opening date as a string.
    • getStringEndDate

      public String getStringEndDate()
      Get the closing date as a string.
      Returns:
      The closing date as a string.
    • setOpeningDate

      public void setOpeningDate(String date) throws DateTimeException
      Set the opening date of the project.
      Parameters:
      date - The new opening date of the project.
      Throws:
      DateTimeException - if the new opening date is after the closing date.
    • setOpeningDate

      public void setOpeningDate(LocalDate date) throws DateTimeException
      Set the opening date of the project.
      Parameters:
      date - The new opening date of the project.
      Throws:
      DateTimeException - if the new opening date is after the closing date.
    • setClosingDate

      public void setClosingDate(String date) throws DateTimeException
      Set the closing date of the project.
      Parameters:
      date - The new closing date of the project.
      Throws:
      DateTimeException - if the new closing date is before the opening date.
    • setClosingDate

      public void setClosingDate(LocalDate date) throws DateTimeException
      Set the closing date of the project.
      Parameters:
      date - The new closing date of the project.
      Throws:
      DateTimeException - if the new closing date is before the opening date.
    • isDateWithin

      public boolean isDateWithin(String date)
      Check if the given date is within the opening and closing dates of the project.
      Parameters:
      date - The date to check.
      Returns:
      true if the date is within the opening and closing dates, false otherwise.
    • isDateWithin

      public boolean isDateWithin(LocalDate date)
      Check if the given date is within the opening and closing dates of the project.
      Parameters:
      date - The date to check.
      Returns:
      true if the date is within the opening and closing dates, false otherwise.
    • getVisibility

      public boolean getVisibility()
      Get the visibility of the project.
      Returns:
      true if the project is visible, false otherwise.
    • toggleVisibility

      public void toggleVisibility()
      Toggle the visibility of the project.
    • setVisibility

      public void setVisibility(boolean visibility)
      Set the visibility of the project.
      Parameters:
      visibility - The new visibility of the project.
    • getManagerInCharge

      public HDBManager getManagerInCharge()
      Get the object of the manager in charge of the project.
      Returns:
      The object of the manager in charge of the project.
    • getTotalOfficerSlots

      public int getTotalOfficerSlots()
      Get the total number of officer slots available for the project.
      Returns:
      The total number of officer slots available for the project.
    • setTotalOfficerSlots

      public void setTotalOfficerSlots(int slots) throws IllegalArgumentException
      Set the total number of officer slots available for the project.
      Parameters:
      slots - The new total number of officer slots available for the project.
      Throws:
      IllegalArgumentException - if the number of slots is negative, is below the number of current officers, or exceeds the maximum number of officers.
    • getOfficers

      public List<HDBOfficer> getOfficers()
      Get the list of officers assigned to the project.
      Returns:
      The list of officers assigned to the project.
    • addOfficer

      public void addOfficer(HDBOfficer officer) throws IllegalArgumentException
      Add an officer to the project.
      Parameters:
      officer - The officer to add.
      Throws:
      IllegalArgumentException - if the officer is null, already registered, or if the project is full.
    • removeOfficer

      public void removeOfficer(HDBOfficer officer) throws IllegalArgumentException
      Remove an officer from the project.
      Parameters:
      officer - The officer to remove.
      Throws:
      IllegalArgumentException - if the officer is not registered or if the project has no officers.
    • addCurrentUserToPendingList

      public void addCurrentUserToPendingList() throws Exception
      Throws:
      Exception
    • removeOfficerFromPendingList

      public void removeOfficerFromPendingList(HDBOfficer officer) throws Exception
      Throws:
      Exception
    • getPendingOfficers

      public List<HDBOfficer> getPendingOfficers()
    • isEligible

      public boolean isEligible(Set<FlatType> flatTypes)
      Check if the given flat types are eligible for application.
      Parameters:
      flatTypes - Set of flat types to check for eligibility.
      Returns:
      true if the project has available units for the given flat types, false otherwise.
    • getHDBOfficersNames

      private List<String> getHDBOfficersNames()
      Get the list of officer names assigned to the project.
      Returns:
      List of officer names assigned to the project.
    • getPendingOfficersNames

      private List<String> getPendingOfficersNames()
      Get the list of pending approval officer's names to the project.
      Returns:
      List of pending approval officer's names assigned to the project.
    • bookFlat

      boolean bookFlat(FlatType type) throws Exception
      Throws:
      Exception
    • toString

      public String toString()
      Get the string representation of the BTO project.
      Overrides:
      toString in class Object
      Returns:
      The string representation of the BTO project.
    • encode

      public String encode()
      Encode the BTO project to a CSV string.
      Specified by:
      encode in interface CSVEncodable
      Returns:
      The CSV string representation of the BTO project.
    • sourceFileType

      public CSVFileTypes sourceFileType()
      Get the type of the source file for the BTO project.
      Specified by:
      sourceFileType in interface CSVEncodable
      Returns:
      The type of the source file for the BTO project.
    • display

      static void display(List<BTOProject> projects, List<BTOProject.TableColumnOption> options)
      Use this to draw a table of projects.
      Parameters:
      projects - List of projects to be displayed.
      options - Additional columns to display.