/**
 
 */
package edu.columbia.cs.cs1007.company;

import java.util.Date;

/**
 * A class that represents an employee of a company.
 
 @author Julia Stoyanovich, COMS 1007, Summer 2009.
 *
 */
public class Employee extends Person {

  // instance variables
  private Company  _company;
  protected Manager _manager;
  private Date       _startDate;
  private double     _salary;
    
  /**
   * Constructor.
   @param person
   @param company
   @param manager
   @param salary
   */
  public Employee(Person person, Company company, Manager manager, double salary) {
    super(person);
    _company = company;
    _manager = manager; 
    _salary = salary;
    _startDate = new Date();
  }

  /**
   * Get hire date of the employee.
   @return date
   */
  public Date getStartDate() {
    return _startDate;
  }
  
  /**
   * Get salary of the employee.
   @return salary
   */
  public double getSalary() {
    return _salary;
  }
  
  /**
   * Get company of the employee.
   @return Company
   */
  protected Company getCompany() {
    return _company;
  }
  /**
   * Do work.
   @param toDo description of the work
   @return progress report
   */
  public String doWork(String toDo) {
    return "Finished " + toDo;
  }

  /**
   * Get a raise for good work.
   @param percentIncrement
   @return new salary
   */
  public double getRaise(double percentIncrement) {
    _salary += _salary*percentIncrement;
    return _salary;
  }
  
  /**
   * Check whether this instance of the Employee equals another instance.
   @return true if the contents are equal, false otherwise
   */
  public boolean equals(Object other) {
    Employee that = (Employeeother;
    
    return (super.equals(other&&       // call the equals method of the superclass
        _company == that._company &&  // _company is a reference
        _manager == that._manager &&  // _manager is a reference
        _startDate.equals(that._startDate&& // _startDate is an object
        _salary == that._salary);             // salary is a fundamental data type
  }
  
  /**
   * Check whether the employee has a manger.
   @return true if the employee has a manger, false otherwise.
   */
  public boolean hasManager() {
    return _manager != null;
  }
  
  /**
   * Generate a string representation of the employee.
   @return string representation
   */
  public String toString() {
    
    StringBuffer result = new StringBuffer(
          super.toString() "\nworks for " + _company.toString() 
          " since " + _startDate.toString() "\n");
    if (hasManager()) {
      result.append("reports to " + _manager.nameToString());
    }
    result.append(", and makes " + _salary + " annually");
    return result.toString();
  }
}