title: Calling method from another class to use in switch statement
body: <p>I'm trying to call a method from my <code>UserController</code> class to my <code>MainController</code>. However i can't seem to instantiate my method and therefore calling it has proved quite difficult.</p>
  
  <p>Also the method I'm calling is to be used in a switch statement. Does this affect how i should go about it at all?</p>
  
  <p>The <code>createUser</code> method. The method works code wise (tried having it in <code>MainController</code>) i just don't know how to instantiate it without doing it
  through a switch statement.</p>
  
  <pre><code>  public static void createUser(){
  
  
     String username, password, repeatPassword, height, weight, address, email;
  
                 int age, choice;
                 double fitnessIndex; 
  
                 String [] rank = {"Guld", "Platinum", "Diamond"};
                 String [] sex = {"Mand","Kvinde"};
  
                  System.out.println("Udfyld følgende for at blive oprettet som bruger: \n ");
  
                  System.out.print("Navn:\n");
                  username = input.nextLine();
  
                  System.out.println("E-mail:  ");
                  email = input.next();
  
  
                  // Regular expression som presierer hva emailen skal inneholde for å være valid
  
                  while (!email.matches("([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\.\\.]+)\\.([a-zA-Z]{2,5})")) {
                      System.out.print("Ugyldig Email, prøv igjen\n");
                      email = input.next(); }
  
  
                  System.out.println("Alder:  ");
                  age = input.nextInt();
  
  
  
                  // Brugeren velger mellom 2 predefinerte koen
                  do {
                      System.out.println("Vælg dit koen: ");
                      data.printArray1(sex);
                      choice = input.nextInt();
                  } while (choice &lt; 1 || choice &gt; sex.length);
  
  
  
                  System.out.println("Hoejde:   ");
                  height = input.next();
  
                  System.out.println("Vaegt:  ");
                  weight = input.next();
  
                  System.out.println("Adresse:   ");
                  address = input.next();
  
                  System.out.println("Kondital:  ");
                  fitnessIndex = input.nextDouble();
  
  
  
                  // Brugeren velger mellom 3 predefinerte muligheter for medlemsskab
  
                  do {
                      System.out.println("Vælg ranken som passer deg bæst: ");
                      data.printArray(rank);
                      choice = input.nextInt();
                  } while (choice &lt; 1 || choice &gt; rank.length);
  
  
                  //beder brugeren om at vælge og gentage sitt kodeord
  
  
                  do {
                      System.out.println("Kodeord:  ");
                      password = input.next();
  
                      System.out.println("Gentag kodeord  ");
                      repeatPassword = input.next();
  
                      if (!password.equals(repeatPassword)) {
                          System.out.println("Kodeordet er forkert, prøv igen!");
                      }
                  } while (!password.equals(repeatPassword));
  
                  User Unapproved = new User(username, password, 1, age, sex[choice-1], height, weight, fitnessIndex, address, email, rank[choice-1]);
                  data.getUnapproveds().add(Unapproved);
  
                  System.out.println("\nDu er nu blivet oprettet som medlem og venter på godkenning ");
                  System.out.println("Så snart du er godkent vil du kunne logge inn, Velkommen til Motion CBS!️\n");
  
          } 
  </code></pre>
  
  <p>Switch statement and me trying to call the method in <code>MainController</code></p>
  
  <pre><code>            do try {
              choice = input.nextInt();
              input.nextLine();
              switch(choice) {
                  case 1:
                      login();
                      break;
  
                  case 2:
                      createUser(); // opret medlemskab
                      break;
  
                  case 3:
                      login();
                      break;
  
                  case 4:
                      onExit();
                      break;
  
                  default:
                      System.out.println("Ugyldigt valg! Prøv igen");
                      break;
              }
          } catch (InputMismatchException eObject) {
              System.out.println("\n Du har indtastet en forkert variabel og bliver nu returnert til stratsiden");
              input.nextLine();
          printStartMenu();
      }
  
      while (currentUser != null);
  }
  
  {
     UserController userController = new UserController();
     userController.createUser();  }
  </code></pre>
  
  <p>So to clarify once again. The method won't be called, since i don't know how to instantiate the method in <code>UserController</code> first. So the CreateUser at the very bottom is RED (not working)</p>
  
  <p>Therefore point 2 in the switch statement doesn't work. Any help and tips are appreciated as i want to understand what i'm missing and why</p>
  
  <p><strong>EDIT</strong>   I understand now that i haven't provided nearly enough information so i'll supplement under here</p>
  
  <p><strong>UserController extends MainController</strong></p>
  
  <pre><code> public class UserController extends MainController {
  
  /**
   * The class constructor. Initializes the class and
   * its super class with instanses of the {@link MainController#data}
   * and {@link MainController#currentUser} objects.
   *
   * @param data        The instantiated data object.
   * @param currentUser The instantiated currentUser object.
   */
  public UserController(Data data, User currentUser) {
      super(data, currentUser);
  }
  </code></pre>
  
  <p><strong>Maincontroller</strong></p>
  
  <pre><code>protected Scanner input = new Scanner(System.in);
  
  /** An instance of the Data class that holds all of the program data */
  protected Data data;
  
  /**
   *  The user currently logged in to the program.
   *  Defaults to null if no user is logged in.
   */
  protected User currentUser;
  
  /**
   * Default constructor for the Main Controller.&lt;br&gt;
   * Should &lt;b&gt;ONLY&lt;/b&gt; be called from the Main Class, and only once.
   */
  
  public MainController() {
      this.data = new Data();
  }
  
  /**
   * Constructor for instantiating when the Main Controller,
   * is the parent of a child controller.
   *
   * @param data          A reference to the instantiated Data object.
   * @param currentUser   A reference to the instantiated User object.
   */
  public MainController(Data data, User currentUser) {
      this.data = data;
      this.currentUser = currentUser;
  }
  </code></pre>