Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String name = "User";
- public static String password = "admin";
- public static void main(String[] args){
- MinOppgave2 login = new MinOppgave2(); //MinOppgave2 is my class
- Scanner sc = new Scanner(System.in);
- boolean exists = true;
- System.out.print("Username: ");
- loginName = sc.nextLine();
- exists = login.check(loginName, false); //false => username
- System.out.print("Password: ");
- loginPassword = sc.nextLine();
- exists = login.check(loginPassword, true); //true => password
- }//end main
- public boolean check(String fetch, boolean usernameOrPassword){
- boolean output = true;
- if (usernameOrPassword){
- //password
- if(fetch == password){
- output = true;
- }else{
- output = false;
- }
- }
- if (!usernameOrPassword){
- //username
- if(fetch == name){
- output = true;
- }else{
- output = false;
- }
- }
- return output;
- }//end check
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement