Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. public class User {
  2.     private String userName;
  3.     private String password;
  4.     private boolean admin;
  5.  
  6.    
  7.     public User(String userName, String password , boolean admin) {
  8.         this.userName = userName;
  9.         this.password = password;
  10.         this.admin = admin;
  11.        
  12.     }
  13.  
  14.     public String getUserName() {
  15.         if (isAdmin(userName,password) && admin == true) {
  16.             return userName;
  17.         }
  18.         return "Access Denied!";
  19.     }
  20.  
  21.     public void setFirstName(String userName) {
  22.         if  (isAdmin(userName,password) && admin == true){
  23.             this.userName = userName;
  24.         }
  25.     }
  26.  
  27.     public String getPassword() {
  28.         if (isAdmin(userName,password)&& admin == true) {
  29.             return password;
  30.         }
  31.         return "Access Denied!";
  32.     }
  33.  
  34.     public void setPassword(String password) {
  35.         if (isAdmin(userName,password)&& admin == true) {
  36.         }
  37.         this.password = password;
  38.     }
  39.    
  40.     public boolean isAdmin(String userName, String password){
  41.         return admin;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement