title: Java - Log in as User or Admin? Inheritance
body: <p>I have a log in system on my application that has a set of predefined users like so:</p>
  
  <pre><code>User user = new User("tommy", "tommy", false);
  User user2 = new User("phil2", "phil2", false);
  User user3 = new User("phil", "phil", true);
  Admin admin = new Admin("benji", "benji", true);
  </code></pre>
  
  <p>These are then added to an array of users</p>
  
  <pre><code>userArray.add(user);...
  </code></pre>
  
  <p>which the logIn() method loops through and checks their credentials against when attempting to log in.</p>
  
  <p>The users can log in as expected, but <strong>how can I get the admin account to log in?</strong> Note the admin is still a User, just a special type of user with a different menu when logged in. Currently the admin account isn't recognised as a user.</p>
  
  <p>In my User class I have this: The Admin inherits from users since it is a user:</p>
  
  <pre><code>public class Admin extends User {           
      public Admin(String username, String password, boolean av) {
          super(username, password,av);
      }
  </code></pre>
  
  <p>LogIn() looks like this:</p>
  
  <pre><code>public void LogIn() {
      Scanner in = new Scanner(System.in);
      System.out.println(" Welcome to the system \n Enter your Username and Password to continue \n Username: ");
      String temp = in.nextLine();
      System.out.println(" Password: ");
      String temp2 = in.nextLine();
  
      //while(LOCount != 3){
      for (int i = 0; i &lt; userArray.size(); i++) {
          if (userArray.get(i).CheckUsername(temp) &amp;&amp; userArray.get(i).CheckPassword(temp2)) {
              // if(userArray.get(i) instanceof User.Admin){
              UserMenu();
  </code></pre>
  
  <p>Checkusername() &amp; checkpassword() as requested:</p>
  
  <pre><code>public Boolean CheckPassword(String password) {         
      return this.password.equals(password);
  }   
  
  public Boolean CheckUsername(String username) {         
      return this.username.equals(username);
  }
  </code></pre>
  
  <p>I'm new with inheritance so any help I would be grateful for, thanks!</p>