I have a problem with this method. It does not output the correct search when the user asks for it.
Here is my code:
System.out.println("Search by Email.");
Employee employeeSearchEmail = MenuMethods.userInputByEmail();
Store.searchByEmail(employeeSearchEmail.getEmployeeEmail());
public Employee searchByEmail(String employeeEmail) {
for (Employee employee : map.values()) {
System.out.println(employee);
map.equals(getClass());
map.equals(employee.getEmployeeEmail());
employee = new Employee(employeeEmail);
;
return employee;
}
return null;
}
public static Employee userInputByEmail() {
// String temp is for some reason needed. If it is not included
// The code will not execute properly.
String temp = keyboard.nextLine();
Employee e = null;
System.out.println("Please enter the Employee Email:");
String employeeEmail = keyboard.nextLine();
// This can use the employeeName's constructor because java accepts the
// parameters instead
// of the name's.
return e = new Employee(employeeEmail);
}
problem is that there is no if condition in your program like this :
this line :
System.out.println(employee);
it will print employee object until it finds the match and when match it will return that employee object..