Assignment 3: Inheritance and Interfaces - Due June 30


Fun with Inheritance and Interfaces and Cloning
  1. Create a Person class. The Person class should have 1 constructor that takes 3 arguments; a name (a string), a SSN (an int), and a date of birth (use your Date Object from Assignment 2). Provide accessors for Name, SSN, and Date of Birth (trap warning: your accessor for DOB should do more than just return it. This may or may not involve adding something to your Date class). toString() and equals() should do their appropriate jobs.

  2. Extend (Inherit from) Person to create an Employee Class. This class should take 4 arguments in the constructor, the 3 for person and an additional Date, for date of hire. The class should have another Date field for Date of hire, and an accessor for it.

  3. Create an Interface called Payable. Payable should define 1 method, getWeeklyPay, which takes in a double called hoursWorked, and returns a double (the weekly pay)

  4. Extend Employee into two different additional classes, HourlyEmployee and SalariedEmployee, which both implement Payable. HourlyEmployee takes an additional argument in the constructor (yes, we're up to 5 in the constructor), a double, which is his hourly rate. SalariedEmployee takes an additional argument, and int, which is his yearly rate. For calculating HourlyEmployee's weekly pay, multiply his hours worked * his rate. For SalariedEmployee, his pay is yearlyrate/52, no matter how many hours he worked.

  5. Make all these classes Cloneable

  6. Create a main, which makes an array of 3 Salaried and 3 Hourly employees, and initialize it with values you choose. Then make a for loop that runs 3 times that calls getWeeklyPay on each Employee with a random number 0-50, and output the Employees name and pay. Your SSN should format in xxx-xx-xxxx as shown below

    Sample Output:

    Employee 1: Joe Shmoe (123-45-6789) - Hours Worked: 33 - Weekly Pay: $744.45
    Employee 2: Dan Cozzi (223-45-6238) - Hours Worked: 13 - Weekly Pay: $1.30
    Employee 3: Steve BuonPane (543-45-6239) - Hours Worked: 45 - Weekly Pay: $643.35
    Employee 4: Jim Fox (124-44-6789) - Hours Worked: 6 - Weekly Pay: $444.23
    Employee 5: Zach Lipsky (122-45-6712) - Hours Worked: 21 - Weekly Pay: $854.54
    Employee 6: Jason Weiss (122-45-5489) - Hours Worked: 43 - Weekly Pay: $1044.95

    Employee 1: Joe Shmoe (123-45-6789) - Hours Worked: 23 - Weekly Pay: $744.45
    Employee 2: Dan Cozzi (223-45-6238) - Hours Worked: 26 - Weekly Pay: $2.60
    Employee 3: Steve BuonPane (543-45-6239) - Hours Worked: 15 - Weekly Pay: $214.48
    Employee 4: Jim Fox (124-44-6789) - Hours Worked: 26 - Weekly Pay: $444.23
    Employee 5: Zach Lipsky (122-45-6712) - Hours Worked: 41 - Weekly Pay: $1668.39
    Employee 6: Jason Weiss (122-45-5489) - Hours Worked: 3 - Weekly Pay: $1044.95

    .. and once more.....
    Also, give me some examples showing your clone() method works (just outputs of Salaried and HourlyEmployee are fine).

  7. Extra Credit 10%: Make your output format neatly (in columns that line up, etc.)


    Be sure to write javadoc comments for your class, and to comment code well. Turn in all your code, your testbed program + run, and your javadoc for all classes.