Employee.java
public class Employee
{
private String name;
private double salary = 0;
/**
* @param args
*
*
*/
public static void main(String[] args, Object name, double salary)
{
/**
* Constructs an employee class.
* @param employeeName the employee name
* @param currentSalary the employee salary
*/
public Employee(String employeeName, double currentSalary)
{
name = employeeName;
salary = currentSalary;
}
/**
* Gets the employee name
* @return name the employee name
*/
public String getName()
{
return name;
}
/**
* Gets the employee salary.
* @return salary the employee salary
*/
public double getSalary()
{
return salary;
}
/**Raises the salary by a given percentage.
* @param percent the percentage of the raise
*/
public void raiseSalary(double percent)
{
Salary = salary * (1 + (percent / 100));
}
}
}
EmployeeTester.java
public class EmployeeTest
{
/**
* @param args
*/
public static void main(String[] args)
{
Employee harry = new Employee("Harry Hacker", 50000);
harry.raiseSalary(10);
System.out.println(harry.getName());
System.out.println("Expected: Harry Hacker 50000");
System.out.println(harry.getSalary());
System.out.println("Expected: 50000");
System.out.println(harry.getSalary());
System.out.println("Expected: 55000");
}
}
And here is the errors
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor Employee(String, int) is undefined
The method raiseSalary(int) is undefined for the type Employee
The method getName() is undefined for the type Employee
The method getSalary() is undefined for the type Employee
The method getSalary() is undefined for the type Employee
at EmployeeTest.main(EmployeeTest.java:10)
I am taking java for school, but I am not a programmer. I have never written code and so some of the info in my book misses me by a mile. It seems to me that I have defined the methods in the class, but....
Please help.
Neil
This post has been edited by spark69: 30 January 2010 - 01:36 PM

New Topic/Question
Reply




MultiQuote











|