Advertisement
Guest User

Untitled

a guest
Sep 8th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static String name = "User";
  2. public static String password = "admin";
  3.  
  4. public static void main(String[] args){
  5. MinOppgave2 login = new MinOppgave2(); //MinOppgave2 is my class
  6. Scanner sc = new Scanner(System.in);
  7. boolean exists = true;
  8. System.out.print("Username: ");
  9. loginName = sc.nextLine();
  10.  
  11. exists = login.check(loginName, false); //false => username
  12.  
  13. System.out.print("Password: ");
  14. loginPassword = sc.nextLine();
  15.  
  16. exists = login.check(loginPassword, true); //true => password
  17.  
  18. }//end main
  19.  
  20. public boolean check(String fetch, boolean usernameOrPassword){
  21. boolean output = true;
  22.  
  23. if (usernameOrPassword){
  24. //password
  25. if(fetch == password){
  26. output = true;
  27. }else{
  28. output = false;
  29. }
  30. }
  31. if (!usernameOrPassword){
  32. //username
  33. if(fetch == name){
  34. output = true;
  35. }else{
  36. output = false;
  37. }
  38. }
  39. return output;
  40. }//end check
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement