/****************************************************************
 *
 * File name: Employee.java
 *
 * Class that extends Person to include the following additional
 *	data items:
 *      annual salary, type double;
 *      hire date (4-digit year), type int; and
 *      social security number, String type (xxx-xx-xxxx)
 *        format preferred.
 *
 *   and these additional methods:
 *      reset modified to change all parameters,
 *      writeOutput modified to write all parameters,
 *      return, change, or write salary,
 *      return, change, or write hire date,
 *      return, change, or write social security number, and
 *      test all parameters to determine if two instances are
 *         equal.
 *
 * Author: Lew Rakocy
 * email address: LRakocy@devrycols.edu
 * Date: 3/7/99
 * Last changed:
 *	9/4/2000	Prologue: email address.
 *				Updated calls to parent methods to work with the
 *					new version of Person class.
 *				Changed method names to be consistent with other
 *					progams in the text: changed "reset" to "set,"
 *					"the..." and to "get...".
 *
 ***************************************************************/

public class Employee extends Person
{
    private double salary; //annual
    private int hireDate; // a four-digit year
    private String ssn; // Social security number (3-2-4 format preferred)

    // Nine constructors

    public Employee()
    {
        super();
        salary = 0;
        hireDate = 1000; // an impossible year
        ssn = "000-00-0000";
    }

    public Employee (String aName)
    {
        super(aName);
        salary = 0;
        hireDate = 1000; // an impossible year
        ssn = "000-00-0000";
    }

    public Employee (String aName, double aSalary)
    {
        super(aName);
        salary = aSalary;
        hireDate = 1000; // an impossible year
        ssn = "000-00-0000";
    }

    public Employee (String aName, int aHireDate)
    {
        super(aName);
        salary = 0;
        hireDate = aHireDate;
        ssn = "000-00-0000";
    }

    public Employee (String aName, String aSsn)
    {
        super(aName);
        salary = 0;
        hireDate = 1000; // an impossible year
        ssn = aSsn;
    }

    public Employee (String aName, double aSalary, int aHireDate )
    {
        super(aName);
        salary = aSalary;
        hireDate = aHireDate;
        ssn = "000-00-0000";
    }

    public Employee (String aName, double aSalary, String aSsn)
    {
        super(aName);
        salary = aSalary;
        hireDate = 1000; // an impossible year
        ssn = aSsn;
    }

    public Employee (String aName, int aHireDate, String aSsn)
    {
        super(aName);
        salary = 0;
        hireDate = aHireDate;
        ssn = aSsn;
    }

    public Employee (String aName, double aSalary, int aHireDate,
                            String aSsn)
    {
        super(aName);
        salary = aSalary;
        hireDate = aHireDate;
        ssn = aSsn;
    }

    // Methods to change, return or write values of data items

    // Change all values
    public void set(String newName, double newSalary,
                        int newHireDate, String newSsn)
    {
        setName(newName);
        salary = newSalary;
        hireDate = newHireDate;
        ssn = newSsn;
    }

    // Write all values
    public void writeOutput()
    {
        super.writeOutput();
        System.out.println("Salary: " + salary);
        System.out.println("Hire date: " + hireDate);
        System.out.println("SSN : " + ssn);
    }

    // Change name: use setName from parent class, Person

    // Return name: use getName from parent class, Person

    // Write name: use writeOutput() from parent class
    public void writeName()
    {
        super.writeOutput();
    }

    // Change salary
    public void setSalary(double newSalary)
    {
        salary = newSalary;
    }

    // Return salary
    public double getSalary()
    {
        return salary;
    }

    // Write salary
    public void writeSalary()
    {
        System.out.println("Annual salary: $" + salary);
    }

    // Change hire date
    public void setHireDate(int newHireDate)
    {
        hireDate = newHireDate;
    }

    // Return hire date
    public int getHireDate()
    {
        return hireDate;
    }

    // Write hire date
    public void writeHireDate()
    {
        System.out.println("Hire date (year): " + hireDate);
    }

    // Change social security number
    public void setSsn(String newSsn)
    {
        ssn = newSsn;
    }

    // Return social security number
    public String getSsn()
    {
        return ssn;
    }

    // Write social security number
    public void writeSsn()
    {
        System.out.println("Social Security #: " + ssn);
    }


    // Equals method
    public boolean equals(Employee otherEmployee)
    {
        return(this.sameName(otherEmployee)
                && this.getSalary() == otherEmployee.getSalary()
                && this.hireDate == otherEmployee.getHireDate()
                && this.ssn.equalsIgnoreCase(otherEmployee.getSsn()));
    }
}

