i am currently stucked on how to create a login algorithm which will login a user based on 2 HashMap objects namely Students and StaffMembers from a class DataStorage, i do not know after getting the texts input from LoginHandler() what do i do with them to compare it with my DataStorage .
/* Class DataStorage*/
public class DataStorage
{
HashMap<String, Student> students = new HashMap<String, Student>();
HashMap<String, Staff> staffMembers = new HashMap<String, Staff>();
//Default constructor
public DataStorage(){
}
public void addStaffMember(Staff aAcc)
{
staffMembers.put(aAcc.getAccID(),aAcc);
}
public void addStudentMember(Student aAcc)
{
students.put(aAcc.getAccID(),aAcc);
}
public Staff getStaffMember(Staff aAcc)
{
return staffMembers.get(aAcc.getAccID());
}
public Student getStudent(Student aAcc)
{
return students.get(aAcc.getAccID());
}
public Account authUser(String user, String pass)
{
}
}
/* Class Account*/
public class Account {
private String name;
private String department;
private String username;
private String password;
private String accountID;
public Account()
{
}
public Account(String nm,String dep,String user,String pass, String accID)
{
name = nm;
department = dep;
username = user;
password = pass;
accountID = accID;
}
public void setName(String nm)
{
name = nm;
}
public String getName()
{
return name;
}
public void setDep(String d)
{
department = d;
}
public String getDep()
{
return department;
}
public void setUser(String u)
{
username = u;
}
public String getUser()
{
return username;
}
public void setPass(String p)
{
password = p;
}
public String getPass()
{
return password;
}
public void setAccID(String a)
{
accountID = a;
}
public String getAccID()
{
return accountID;
}
}
/* Class Staff extends account*/
public class Staff extends Account {
public Staff(String n, String id, String dep, String user, String pass)
{
super(n, dep, user, pass, id);
}
}
/** Class Student extends Account**/
public class Student extends Account {
private String studentNRIC;
public Student(String n, String nr, String id, String dep, String user, String pass)
{
super(n, dep, user, pass, id);
studentNRIC = nr;
}
public void setStudentNRIC(String nr)
{
studentNRIC = nr;
}
public String getStudentNRIC()
{
return studentNRIC;
}
}
/* class loginHandler which will handle a login button/
class LoginHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String tempUser;
String tempPass;
tempUser = txfUser.getText();
tempPass = txfPass.getText();
}
}