Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 629049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:42:11+00:00 2026-05-13T19:42:11+00:00

i am currently stucked on how to create a login algorithm which will login

  • 0

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();

  }

 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:42:11+00:00Added an answer on May 13, 2026 at 7:42 pm

    First of all you should change the getters in DataStorage to have String parameters, so that you can look up a student (or staff member) based on her account ID:

    public Student getStudent(String aAcc)
    {
        return students.get(aAcc);
    }
    

    You can then lookup the username in actionPerformed, like

    Student student = dataStorage.getStudent(tempUser);
    if (student != null && student.getPass().equals(tempPass))
    {
        // login successful
        ...
    } else {
        // Login failed - display error message
    }
    

    Similarly for staff members.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have 2 ways of displaying images in a cell, which way will
I'm currently a bit stucked in exif. I extract the thumbnail from the JPEG
I'm currently trying to create buttons which are in the form of loosely stacked
Currently I am using HTML files for parts of my user interface. I display
I want to create a simple affiliate code. Currently I use PHP session to
I need to create bazaar workspace for 4 developers. Each developer will work on
I'm investigating Zend Framework and currently stucked in counting resulting rows of sql query...
From my experience this is what i come up with. Im currently saving Users
I am currently developing an App based on a Navigation Controller. However, when the
Im currently developing a project using Google Maps. The whole function that im stucked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.