public void printUsers() // a function to print all users { for (int i = 0; i < user_list.Count; i++) { M_users user = (M_users)user_list[i]; //takes out objects from list and convert them to class of M_users Console.WriteLine(user.getName()); } }
private ArrayList user_list = new ArrayList(); //declaring a list to store users public void addUser(string username, string password) //a function to add users { M_users u1 = new M_users(); //creating a object of class M_users from line127 u1.setName(username); u1.setPin(password); user_list.Add(u1); //appending the object in list }
public string isValidUser(string name, string password) //a function to check if the user exists { for (int i = 0; i < user_list.Count; i++) { M_users user = (M_users)user_list[i]; if (user.getPin() == password && user.getName() == name) { logged_in = name; return("user"); //if user exists } } return("false"); //if user does not exist }