Create a class that represents an employee. This class will have three constructors to initialize variables. If the constructor doesn't provide a parameter for a field, make it either "(not set)" or "0" as appropriate. Name: Employee Fields:
- name : String
- idNumber : int
- department : String
- position : String Methods:
- Employee()
- Employee(name : String, idNumber : int)
- Employee(name : String, idNumber : int, department : String, position : String)
- getName() : String
- getDepartment() : String
- getPosition() : String
- getIdNumber() : int
My issue is that I don't know if the Employee() field is a void Also not sure why public class Employee is included in the comment rather than the code.
public class Employee {
private String name;
private int idNumber;
private string department;
private string position;
/* public void setEmployee (String n)
{
name = n;
if (n == null)
{
n = "(not set)";
}
}
public void Employee (string n, int id)
{
name = n;
idNumber =id;
}
public void Employee (string n, int id, string d, string p)
{
name = n;
idNumber = id;
department = d;
position = p;
} */
public String getName ()
{
return name;
}
public string getDepartment ()
{
return department;
}
public string getPosition ()
{
return position;
}
public int getIdNumber ()
{
return idNumber;
}
}
Also having an issue with this second part Not sure where to go from here
import java.util.Scanner;
public class EmployeeDem {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String option;
do {
System.out.println("-- Employee ID Menu --\n Enter 'exit' to quit");
option = keyboard.nextLine();
System.out.println("What is your name?");
String name = keyboard.nextLine();
System.out.println("What is your ID number?");
int idNumber = keyboard.nextInt();
System.out.println("What is your department?");
String department = keyboard.nextLine();
System.out.println("What is your position?");
String position = keyboard.nextLine();
} while (option != "exit");
//class obj instance
Employee myEmployee = new Employee();
myEmployee.
}
}