Employee Class


/**
 *Employee has a name and salary that can be changed; the salary can be raised by a percentage.
 */
public class Employee
{
	
	private String name;
	private double salary;
	
	
	/**
	 *Creates an employee with no name and no salary.
	 */
	public Employee()
	{
		name="";
		salary=0;
	}
	
	/**
	 *Creates an employee with a name, but no salary.
	 *@param name Specifies name of employee.
	 */
	public Employee(String newName)
	{
		name=newName;
		salary=0;
	}
	
	/**
	 *Creates an employee with no name, but a salary.
	 *@param salary Specifies salary of employee.
	 */
	public Employee(double newSalary)
	{
		name="";
		salary=newSalary;
	}
	
	/**
	 *Creates an employee with a name and salary.
	 *@param name Specifies name of employee.
	 *@param salary Specifies salary of employee.
	 */
	public Employee(String newName, double newSalary)
	{
		name=newName;
		salary=newSalary;
	}

	
	/**
	 *Sets the name of the employee.
	 *@param Specifies the name of the employee.
	 */
	public void setName(String newName)
	{
		name=newName;
	}
	
	/**
	 *Sets the salary of the employee.
	 *@param salary Specifies salary of employee.
	 */
	 public void setSalary(newSalary)
	 {
	 	salary=newSalary;
	 }
	 
	 
	 /**
	  *Returns employee's name.
	  *@return Returns the name.
	  */
	  public String getName()
	  {
	  	return name;
	  }
	  
	  /**
	   *Returns employee's salary.
	   *@return Returns the salary.
	   */
	   public double getSalary()
	   {
	   		return salary;
	   }
	   
	   
	   /**
	    *Gives the employee a raise by the specified percentage.
	    *@param percent Specfies the percent to raise the salary by.
	    */
	    public void raiseSalary(int percent)
	    {
	    	salary+=salary*(percent/100);
	    }
}



Home
Site hosted by Angelfire.com: Build your free website today!