Guest User

Untitled

a guest
Apr 10th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import java.util.HashMap;
  2.  
  3. public class login
  4. {
  5. // instance variables - replace the example below with your own
  6. private String username = "Jason";
  7. private String password = "Password";
  8.  
  9. HashMap <String, String> db = new HashMap<String, String>();
  10.  
  11. /**
  12. * Constructor for objects of class login
  13. */
  14. public login()
  15. {
  16. db.put("Test", "Pass");
  17. db.put("Jason", "Password");
  18. }
  19.  
  20. public boolean auth(String user, String pass){
  21. String passToCheck = db.get(user);
  22. if (passToCheck != null) {
  23. System.out.println("Found");
  24. return pass == passToCheck;
  25.  
  26. } else {
  27. System.out.println("Not Found");
  28. return false;
  29.  
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment