Still learning Java, bit of an idiot and I apologize for the trouble. I have a question with regards to using user input from a main.class with an employee.class with getters and setters and returning those back to the main.class. Is this the correct way of using methods from the employee.class with user input? Would it be okay to just point me to the right direction.
Here's the Employee.class which needed a default value of true.
public class Employee() {
private String id = "100";
private boolean manager = true;
public Employee(String id, String name, int numOfYears) {
this.id = id;
this.name = name;
this.numOfYears = numOfYears;
}
public Employee(String id, String name, int numOfYears, double
monthlySalary, boolean manager) {
this.id = id;
this.name = name;
this.numOfYears = numOfYears;
this.monthlySalary = monthlySalary;
this.manager = manager;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean getManager() {
return manager;
}
public void setManager(boolean manager) {
if (manager == true) {
System.out.println("Yes");
this.manager = manager;
} else {
System.out.println("No");
this.manager = manager;
}
}
}
And here's the Main.class
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter employee ID:");
int i = input.nextInt();
String id = Integer.toString(i);
System.out.println("In management? True/False");
boolean manager = input.nextBoolean();
Employee empId = new Employee(id);
empId.setId(id);
Employee empManager = new Employee();
empManager.setManager();
}
}
Would the correct way to input the user values be
Employee empManager = new Employee(manager);
empManager.setManager();
I'm not sure if I could ask, but I feel like I probably have more errors, if it'd be okay to just nudge in the right direction.
public Employee(String id)itself is missing fornew Employee(id);to work correctly