This is for a beginning Java course that poses the problem:
Write a class named Employee that has the following fields:
name
. Thename
field references a String object that holds the employee's name.idnumber
. Theidnumber
is an int variable that holds the employee's id number.department
. Thedepartment
field references a String object that holds the name of the department where the employee works.position
. Theposition
field references a String object that holds the employee's job title.
I am aware there is a similar question on these boards, but my problem does not include constructors, and the posted one does.
First, my public class java file:
public class employee {
private String name;
private int idnumber;
private String department;
private String position;
public void setName(String n){
name = n;
}
public void setID(int id){
idnumber = id;
}
public void setDepartment(String d){
department = d;
}
public void setPosition(String p){
position = p;
}
public String getName(){
return name;
}
public int getID(){
return idnumber;
}
public String getDepartment(){
return department;
}
public String getPosition(){
return position;
}
}
Second, my main class code:
public class EmployeeFile {
public static void main (String[] args)
{
employee One = new employee();
employee Two = new employee();
employee Three = new employee();
One.setName("Susan Meyers");
One.setID(47899);
One.setDepartment("Accounting");
One.setPosition("Vice President");
Two.setName("Mark Jones");
Two.setID(39119);
Two.setDepartment("IT");
Two.setPosition("Programmer");
Three.setName("Joy Rogers");
Three.setID(81774);
Three.setDepartment("Manufacturing");
Three.setPosition("Engineer");
System.out.println("Name ID Number Department Position");
System.out.println("____________________________________________________________________");
System.out.println(One.getName()+"\t"+One.getID()+"\t"+One.getDepartment()+"\t"+One.getPosition());
}
}
This is the error I get:
run: Error: Could not find or load main class employee.EmployeeFile Java Result: 1
Any help, pointers or redirections to a previous solution I may have overlooked is much, much appreciated!