Our company deals with people. Every Person has these fields:

  • givenName (String)
  • surname (String)
  • phoneNumber (String)
  • streetAddress (String)
  • city (String)
  • state (string)
  • zip (int)
  • zipPlus4(int)

The Person class requires some methods:

  • A 2-arg constructor that takes givenName and surname, and creates a person, filling all other String fields with “unknown”, and 99999 for zip, and 9999 for zipPlus4.
  • An 8-arg constructor that takes all eight fields
  • A toString() methods that returns a multi-line string suitable for printing on an envelope for mailing.
  • gets and sets for all fields.
  • A .equals(Person other) methods that returns true if both givenName and Surname match, false otherwise.

In addition, we have Customers. Each Customer is a Person. In addition, a customer has these extra fields:

  • customerID (int)
  • creditLimit (double)
  • balanceOwed (double)

The Customer class needs these methods:

  • A 3-arg constructor (surname, givenName, customerID) that creates a new customer with a zero balanceOwed.
  • A charge(double amount) method that adds amount to the current balanceOwed
  • A credit(double amount) method that credits a customer’s account. It should not directly access the balanceOwed field, but use the charge() method with a negative number.
  • gets and sets for creditLimit.
  • gets for customerID and balanceOwed, but no sets for them. (all changes should be trackable through the single credit() method.)
  • A different equals method that compares customerIDs.

We also have employees. The Employee class needs these fields:

  • salaried (boolean)
  • wages (double), which will be interpreted as hourly for salaried==false, and annual salary otherwise.
  • employeeID (integer)

Employee will need methods:

  • A 4-arg constructor that uses givenName, surname, salaried, and employeeID.
  • gets and sets for wages and salaried (but instead of a get for a Boolean, use an isSalaried()), but only a get for employeeID.
  • An equals method that compares employeeIDs.

Week01.java will be a tester program. It should:

  • Have an ArrayList of Customer
  • Have an ArrayList of Employee
  • A GUI interface (Preferably built with Window Builder) that has
    • Fields for all possible fields for both customers and employees
    • three buttons:
    • Add Customer (with appropriate fields) For extra credit, warn if same ID already there.
    • Add Employee (ditto) For extra credit, warn if same ID already there.
    • Display All This should list out first customers, then employees, using console output.

Be sure to implement all methods exactly as specified, because I may hook your classes up to my own tester program! You will have these classes, each in its own file:

  • Person.java
  • Customer.java
  • Employee.java
  • Week01.java

Every .java file should have as its first line a comment with your name in it.

When your program runs, your name should appear in the title bar of the window.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.