Samasaur1 / CityManagement

A text-based city management game
3 stars 7 forks source link

Problem when checking if amounts are valid #22

Closed Samasaur1 closed 6 years ago

Samasaur1 commented 6 years ago

Describe the bug When buying/selling/constructing, for the amount, if any digits are included the game treats it as a valid number

To Reproduce Steps to reproduce the behavior:

  1. Type buy food 1a after passing setup
  2. See error

Expected behavior It should say Error 1.3.2: Not a valid amount and go to the next day.

Screenshots

Screen Shot

Desktop (please complete the following information):

Stack trace

Exception in thread "main" java.lang.NumberFormatException: For input string: "1a"
  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  at java.lang.Integer.parseInt(Integer.java:580)
  at java.lang.Integer.parseInt(Integer.java:615)
  at com.samgauck.CityManagement.Command.buy(Command.java:114)
  at com.samgauck.CityManagement.Command.execute(Command.java:62)
  at com.samgauck.CityManagement.Main.main(Main.java:149)