Package sc2002.FCS1.grp2
Class FlatInfo
Object
FlatInfo
- All Implemented Interfaces:
CSVEncodable
Class representing information about a flat in the HDB project.
This class implements the CSVEncodable interface to allow encoding of its data into a CSV format.
The class contains information about the flat type, the number of remaining units, and the price of the flat.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe price of the flat type.private intThe number of remaining units of the flat type.private FlatTypeEnum representing the type of flat. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionencode()Encodes the FlatInfo object into a CSV format string.intgetPrice()Returns the price of the flat type.intReturns the number of remaining units of the flat type.getType()Returns the type of flat.voidsetPrice(int price) Sets the price of the flat type.voidsetRemainingUnits(int remainingUnits) Sets the number of remaining units of the flat type.voidSets the type of flat.Returns the type of the source file for this object.
-
Field Details
-
type
Enum representing the type of flat. -
remainingUnits
private int remainingUnitsThe number of remaining units of the flat type. -
price
private int priceThe price of the flat type.
-
-
Constructor Details
-
FlatInfo
FlatInfo(FlatType type, int remainingUnits, int price) Constructor to create a FlatInfo object with specified type, remaining units, and price.- Parameters:
type- the type of flatremainingUnits- the number of remaining units of the flat typeprice- the price of the flat type
-
-
Method Details
-
getType
Returns the type of flat.- Returns:
- the type of flat
-
getRemainingUnits
public int getRemainingUnits()Returns the number of remaining units of the flat type.- Returns:
- the number of remaining units
-
getPrice
public int getPrice()Returns the price of the flat type.- Returns:
- the price of the flat type
-
setType
Sets the type of flat.- Parameters:
type- the new type of flat
-
setRemainingUnits
public void setRemainingUnits(int remainingUnits) Sets the number of remaining units of the flat type.- Parameters:
remainingUnits- the new number of remaining units
-
setPrice
public void setPrice(int price) Sets the price of the flat type.- Parameters:
price- the new price of the flat type
-
encode
Encodes the FlatInfo object into a CSV format string. The format is: type,remainingUnits,price- Specified by:
encodein interfaceCSVEncodable- Returns:
- the encoded CSV string representation of the FlatInfo object
-
sourceFileType
Returns the type of the source file for this object. In this case, it returns null as FlatInfo does not have a specific source file type.- Specified by:
sourceFileTypein interfaceCSVEncodable- Returns:
- null
-