Package Model
Class Customer
java.lang.Object
Model.Customer
The Customer class represents a customer in the utility management system.
It encapsulates essential customer information, including the username,
password, and email associated with the customer.
Usage
To use this class, create an instance ofCustomer
and populate it
with the necessary customer details.
Example Usage
Customer customer = new Customer("username", "password", "email@example.com");
Attributes
username
: The username of the customer.password
: The password of the customer.email
: The email address of the customer.
File Management
Customer data is stored in a text file specified by thecustomersFilePath
attribute.
This class provides methods to load customers from the file and save
customers to the file.
Thread Safety
This class is not thread-safe, so external synchronization may be required when accessed by multiple threads.- See Also:
-
CustomerController
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
The email of the Customer.private String
The password of the Customer.private String
The username of the Customer.(package private) static WrittenBills
The WrittenBills instance for the Customer. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a utility bill for the Customer.void
deleteBill
(int billId) Deletes a utility bill for the Customer.void
editBill
(int billId, double newMeterMeasurement) Edits a utility bill for the Customer.getBills()
Gets all utility bills for the Customer.getEmail()
Gets the email of the Customer.Gets the password of the Customer.Gets the username of the Customer.void
Sets the email of the Customer.void
setPassword
(String password) Sets the password of the Customer.void
setUsername
(String username) Sets the username of the Customer.
-
Field Details
-
username
The username of the Customer. -
password
The password of the Customer. -
email
The email of the Customer. -
writtenBills
The WrittenBills instance for the Customer.- See Also:
-
-
Constructor Details
-
Customer
Constructs a Customer instance with the specified username, password, and email.- Parameters:
username
- The username of the customer.password
- The password of the customer.email
- The email of the customer.
-
-
Method Details
-
getUsername
Gets the username of the Customer.Method Details
This method retrieves the username of the Customer by calling the function.- Returns:
- String representing the username.
-
setUsername
Sets the username of the Customer.Method Details
This method sets the username of the Customer by setting the username to the username attribute.- Parameters:
username
- The new username.
-
getPassword
Gets the password of the Customer.Method Details
This method retrieves the password of the Customer by calling the function.- Returns:
- String representing the password.
-
setPassword
Sets the password of the Customer.Method Details
This method sets the password of the Customer by setting the password to the password attribute.- Parameters:
password
- The new password.
-
getEmail
Gets the email of the Customer.Method Details
This method retrieves the email of the Customer by calling the function.- Returns:
- String representing the email.
-
setEmail
Sets the email of the Customer.Method Details
This method sets the email of the Customer by setting the email to the email attribute- Parameters:
email
- The new email.
-
addBill
Adds a utility bill for the Customer.Method Details
This method adds a utility bill for the Customer by calling the function. and passing the parameters to the addBill function in WrittenBills.- Parameters:
utilityType
- The type of utility.meterMeasurement
- The meter measurement.date
- The date of the bill.- See Also:
-
editBill
public void editBill(int billId, double newMeterMeasurement) Edits a utility bill for the Customer.Method Details
This method edits a utility bill for the Customer by passing the parameters to editBill function in WrittenBills.- Parameters:
billId
- The ID of the bill to be edited.newMeterMeasurement
- The new meter measurement.- See Also:
-
deleteBill
public void deleteBill(int billId) Deletes a utility bill for the Customer.Method Details
This method deletes a utility bill for the Customer by passing the bill id to deleteBill function in WrittenBills.- Parameters:
billId
- The ID of the bill to be deleted.- See Also:
-
getBills
Gets all utility bills for the Customer.Method Details
This method gets all utility bills for the Customer by calling the loadBills function of written bills and adding them in an arraylist.- Returns:
- ArrayList of UtilityBill representing the bills.
- See Also:
-