Package Model

Class Customer

java.lang.Object
Model.Customer

public class Customer extends Object
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 of Customer 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 the customersFilePath 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 Details

    • username

      private String username
      The username of the Customer.
    • password

      private String password
      The password of the Customer.
    • email

      private String email
      The email of the Customer.
    • writtenBills

      static WrittenBills writtenBills
      The WrittenBills instance for the Customer.
      See Also:
  • Constructor Details

    • Customer

      public Customer(String username, String password, String email)
      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

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

      public void setUsername(String username)
      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

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

      public void setPassword(String password)
      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

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

      public void setEmail(String email)
      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

      public void addBill(String utilityType, double meterMeasurement, String date)
      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

      public ArrayList<UtilityBill> 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: