I'm trying to make a system without MySQL database which will have accounts and accounts' data. But it didn't work
My accounts java file:
/*
* Instead of using 2 different ArrayList (for Username and Password) we used Hashmap
* HashMap stores keys and the keys' values
* In our HashMap keys refer to usernames values refer to passwords
*/
import java.util.HashMap;
import javax.swing.JOptionPane;
public class Accounts {
//I used static to reach list from another class suggest me another way please
static HashMap AccountList = new HashMap<String, HashMap<String, String>>();
public static void CreateAccount(String userID, String password, String email, String fullName, String department){
//We have to check that there shouldn't be an account with the same username
if (AccountList.containsKey(userID)){
JOptionPane.showMessageDialog(null, "There is an account with that username");
}
else{
HashMap Data = new HashMap<String, String>();
Data.put("userID", userID);
Data.put("password", password);
Data.put("email", email);
Data.put("fullName", fullName);
Data.put("department", department);
AccountList.put(userID, Data);
JOptionPane.showMessageDialog(null, "Member created successfully");
}
}
}
In my login.java I get an error on that line
boolean IsLoginSuccessful = false;
//We are getting username and password text/string from the form
String userID = username_field.getText();
String password = password_field.getText();
//Now check if username is in list then check if username's password equals to password
if (Accounts.AccountList.containsKey(userID)){
String userPassword = Accounts.AccountList.get(userID).get("password");
IsLoginSuccessful = true;
}
That second ".get" gives error like "cannot find symbol". Why does it take the hashmap as an object element? Also if you have another way to store these datas without hashtable and check the password etc. Show me please thank you.