Am I writing an RPG combat system from scratch in Java, ambitious? Well, I have a problem. This is my code:
void turnChoice() { System.out.println("What will you do? Say (Fight) (Run) (Use Item)"); Scanner turnChoice = new Scanner(System.in); switch (turnChoice.nextLine()) { case ("Fight"): Combat fighting = new Combat(); fighting.fight(); default: } turnChoice.close(); }
When it gets to this point in the code, I get:
What are you going to do? Say (Combat) (Run) (Use item)
Exception in thread "main" java.util.NoSuchElementException: row not found
at java.util.Scanner.nextLine (Unknown source)
at Combat.turnChoice (Combat.java:23)
The class is called Combat, I just want it to give the opportunity to fight, launch or use elements, first I try to use the battle method. Please help, I'm new to Java, so don't make things too complicated if possible.
source share