So I know I need to add a few more lines somewhere to make this work, but I'm not sure how.
[PHP]
// Lab 3: EmployeeTest.java
// Application to test class Employee.
/* Begin class declaration of EmployeeTest class. */
public class EmployeeTest
{
/* Begin main method declaration. */
public static void main (String arg [])
{
/* Create two Employee objects and assign them to Employee variables. */
Employee emp1 = new Employee("Bob", "Jones", 2875);
Employee emp2 = new Employee("Susan", "Baker", 3150.75);
/* Output the first name, last name and salary for each Employee. */
System.out.printf("Employee 1: %s %s; Yearly Salary: %.2f\n", emp1.getFirstname(), emp1.getLastName(), emp1.getEmployeeSalary());
System.out.printf("Employee 2: %s %s; Yearly Salary: %.2f\n", emp2.getFirstname(), emp2.getLastName(), emp2.getEmployeeSalary());
/* Give each Employee a 10% raise. */
double salary1 = emp1.getEmployeeSalary()*1.1;
emp1.setEmployeeSalary(salary1);
double salary2 = emp2.getEmployeeSalary()*1.1;
emp2.setEmployeeSalary(salary2);
/* Output the first name, last name and salary of each Employee again. */
System.out.printf("Employee 1: %s %s; Yearly Salary: %.2f\n", emp1.getFirstname(), emp1.getLastName(), emp1.getEmployeeSalary());
System.out.printf("Employee 2: %s %s; Yearly Salary: %.2f\n", emp2.getFirstname(), emp2.getLastName(), emp2.getEmployeeSalary());
/* End main method declaration */
}
/* End class declaration of EmployeeTest class. */
}
[/PHP]
I have another class in this same project that has somewhat to do with this one.
[PHP]
/**
* Write a description of class Employee here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Employee
{
// instance variables - replace the example below with your own
private String firstName;
private String lastName;
private double salary;
/**
* Constructor for objects of class Employee
*/
public Employee(String fName, String lName, double Sal)
{
// initialise instance variables
firstName = fName;
lastName = lName;
salary = Sal;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public double getEmployeeSalary()
{
// put your code here
return salary;
}
public void setEmployeeSalary(double sal)
{
// put your code here
if(sal >= 0.0)
salary = sal;
}
}
[/PHP]
The general idea is that the program prints out the names of the employees and then their salary, then gives them a 10% raise and then prints it back out. The problem is that the employeetest class doesn't have the .getFirstname method and I don't know where to put it. Any help would be apreciated.