title: Using Scanner to take input from two objects of the same class
body: <p>I have a problem with functionality of my simple program I am making at the moment. I am trying to create two objects, each of them is asking user to provide a name and then choose from few options, by using <code>Scanner</code>. First object, monster of class <code>createMonster</code>, is asking user to provide information through Scanner. However, while creating second object <code>monster2</code> of class <code>createMonster</code>, program does not asking for user input. </p>
  
  <p>Do I need to do some changes in my class <code>CreateScanner</code> or is it a bigger problem?</p>
  
  <pre><code>public class MainClass {
  
      public static void main(String[] args) {
          RandomMonsterGenerator monster = new RandomMonsterGenerator();
          monster.createMonster();
          RandomMonsterGenerator monster2 = new RandomMonsterGenerator();
          monster2.createMonster();
      }
  }
  </code></pre>
  
  <p><code>RandomMonsterGenerator</code> code:</p>
  
  <pre><code>public class RandomMonsterGenerator {
  
      // Objects
      Attributes attr = new Attributes();
      CreateScanner createScanner = new CreateScanner();
  
      // Variables
      String monsterName;
      String attributesValues;
      int choice;
  
      // Main method for generating monster
      public void createMonster() {
          attr.generateAttributes();
          generateName();
          chooseClass();
          System.out.println("Generating random stats:");
          attributesValues = attr.toString();
          System.out.println(attributesValues);
          createScanner.closeScanner();
      }
  
      // Generating monster name
      private void generateName() {
          System.out.println("Name your monster: ");
          monsterName = createScanner.stringInput();
          System.out.println("Name of the monster: " + monsterName);
      }
  
      // Choosing a class
      private void chooseClass() {
          System.out.println("Class descriptions: ");
          System.out.println("Warrior has +2 to Strength and +2 to Condititon.");
          System.out.println("Thief has +2 to Dexterity and +2 to Charisma.");
          System.out.println("Mage has +2 to Intelligence and +2 to Wisdom.");
          System.out.println("**************************************************");
          System.out.println("Choose your class from following options: ");
          System.out.println("Warrior, press '1'");
          System.out.println("Thief, press '2'");
          System.out.println("Mage, press '3'");
          choice = createScanner.intInput();
          switch(choice) {
              case 1:
                  Warrior warrior = new Warrior(attr);
                  System.out.println(monsterName + " is a warrior.");
                  break;
              case 2:
                  Thief thief = new Thief(attr);
                  System.out.println(monsterName + " is a thief.");
                  break;
              case 3:
                  Mage mage = new Mage(attr);
                  System.out.println(monsterName + " is a mage.");
                  break;
              default:
                  System.out.println("No option choosen.");
                  break;
          }
      }
  }
  </code></pre>
  
  <p><code>CreateScanner</code> code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class CreateScanner {
  
      Scanner sc = new Scanner(System.in);
  
      public String stringInput() {
          String input = "";
          if (sc.hasNextLine()) {
              input = sc.nextLine();
          }
          return input;
      }
      public int intInput() {
          int input2 = 0;
          if (sc.hasNextLine()) {
              input2 = sc.nextInt();
          }
          return input2;
      }
      public void closeScanner() {
          sc.close();
      }
  }
  </code></pre>