Package sc2002.FCS1.grp2
Class BTOProject
Object
CSVDecodable
BTOProject
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumOptions to decide which columns to be displayed -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LocalDateclosing date of projectflat info, based on flat typeprivate HDBManagerthe manager in charge of this projectprivate Stringtemporary value for decoding and linking purposes.private static intNumber of officers at maxprivate Stringneighbourhood which project belong totemporary value for decoding and linking purposes.private List<HDBOfficer> officers of this projectprivate LocalDateOpening date of projecttemporary value for decoding and linking purposes.private List<HDBOfficer> Officers that are pending approvalprivate Stringname of projectprivate intslots of project, for project.private booleanwhether this is pubically visible -
Constructor Summary
ConstructorsConstructorDescriptionBTOProject(String projectName, String neighborhood, int maxTwoRoomUnits, int maxThreeRoomUnits, int twoRoomPrice, int threeRoomPrice, LocalDate openingDate, LocalDate closingDate, HDBManager managerInCharge, int totalOfficerSlots) Constructor for BTOProject class when manager creates a new BTOProject.BTOProject(List<CSVCell> cells) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddOfficer(HDBOfficer officer) Add an officer to the project.(package private) booleanbooleancontainsUnitsThatFitsPriceRange(int min, int max) (package private) static voiddisplay(List<BTOProject> projects, List<BTOProject.TableColumnOption> options) Use this to draw a table of projects.encode()Encode the BTO project to a CSV string.getApplicableFlats(Set<FlatType> applicableTypes) Get the applicable flat information for specific flat types.Get the closing date of the project.getFlatForType(FlatType type) Get the flat information for a specific flat type.Get the list of officer names assigned to the project.Get the object of the manager in charge of the project.Get the neighborhood of the BTO project.Get the list of officers assigned to the project.Get the opening date of the project.Get the list of pending approval officer's names to the project.Get the project name of the BTO project.Get the closing date as a string.Get the opening date as a string.intGet the price of three room units in the project.intGet the number of three room units available in the project.intGet the total number of officer slots available for the project.intGet the price of two room units in the project.intGet the number of two room units available in the project.booleanGet the visibility of the project.booleanisDateWithin(String date) Check if the given date is within the opening and closing dates of the project.booleanisDateWithin(LocalDate date) Check if the given date is within the opening and closing dates of the project.booleanisEligible(Set<FlatType> flatTypes) Check if the given flat types are eligible for application.voidremoveOfficer(HDBOfficer officer) Remove an officer from the project.voidremoveOfficerFromPendingList(HDBOfficer officer) voidretrieveConnectedUsers(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.voidsetClosingDate(String date) Set the closing date of the project.voidsetClosingDate(LocalDate date) Set the closing date of the project.voidsetNeighborhood(String neighborhood) Set the neighborhood of the BTO project.voidsetOpeningDate(String date) Set the opening date of the project.voidsetOpeningDate(LocalDate date) Set the opening date of the project.voidsetProjectName(String name) Set the project name of the BTO project.voidsetThreeRoomPrice(int threeRoomPrice) Set the price of three room units in the project.voidsetThreeRoomUnits(int threeRoomUnits) Set the number of three room units available in the project.voidsetTotalOfficerSlots(int slots) Set the total number of officer slots available for the project.voidsetTwoRoomPrice(int twoRoomPrice) Set the price of two room units in the project.voidsetTwoRoomUnits(int twoRoomUnits) Set the number of two room units available in the project.voidsetVisibility(boolean visibility) Set the visibility of the project.Get the type of the source file for the BTO project.voidToggle the visibility of the project.toString()Get the string representation of the BTO project.
-
Field Details
-
projectName
name of project -
neighborhood
neighbourhood which project belong to -
flats
flat info, based on flat type -
openingDate
Opening date of project -
closingDate
closing date of project -
managerName
temporary value for decoding and linking purposes. -
managerInCharge
the manager in charge of this project -
totalOfficerSlots
private int totalOfficerSlotsslots of project, for project. does not decrement -
officerNames
temporary value for decoding and linking purposes. -
officers
officers of this project -
visibility
private boolean visibilitywhether this is pubically visible -
pendingOfficerNames
temporary value for decoding and linking purposes. -
pendingOfficers
Officers that are pending approval -
MAX_OFFICER_NUM
private static int MAX_OFFICER_NUMNumber of officers at max
-
-
Constructor Details
-
BTOProject
- 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
Retrieve the connected officers and manager as an object for this project by comparing the names the project has.- Parameters:
officers- List of officer objectsmanagers- List of manager objects
-
containsUnitsThatFitsPriceRange
public boolean containsUnitsThatFitsPriceRange(int min, int max) -
getProjectName
Get the project name of the BTO project.- Returns:
- the project name of the BTO project.
-
setProjectName
Set the project name of the BTO project.- Parameters:
name- the new project name of the BTO project.
-
getNeighborhood
Get the neighborhood of the BTO project.- Returns:
- the neighborhood of the BTO project.
-
setNeighborhood
Set the neighborhood of the BTO project.- Parameters:
neighborhood- the new neighborhood of the BTO project.
-
getApplicableFlats
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
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
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
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
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
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
Get the opening date of the project.- Returns:
- The opening date of the project.
-
getClosingDate
Get the closing date of the project.- Returns:
- The closing date of the project.
-
getStringOpeningDate
Get the opening date as a string.- Returns:
- The opening date as a string.
-
getStringEndDate
Get the closing date as a string.- Returns:
- The closing date as a string.
-
setOpeningDate
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
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
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
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
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
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
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
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
Get the list of officers assigned to the project.- Returns:
- The list of officers assigned to the project.
-
addOfficer
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
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
- Throws:
Exception
-
removeOfficerFromPendingList
- Throws:
Exception
-
getPendingOfficers
-
isEligible
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
Get the list of officer names assigned to the project.- Returns:
- List of officer names assigned to the project.
-
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
- Throws:
Exception
-
toString
Get the string representation of the BTO project. -
encode
Encode the BTO project to a CSV string.- Specified by:
encodein interfaceCSVEncodable- Returns:
- The CSV string representation of the BTO project.
-
sourceFileType
Get the type of the source file for the BTO project.- Specified by:
sourceFileTypein interfaceCSVEncodable- Returns:
- The type of the source file for the BTO project.
-
display
Use this to draw a table of projects.- Parameters:
projects- List of projects to be displayed.options- Additional columns to display.
-