From ad8a07cf736913d756d5100efb517e19d10efdde Mon Sep 17 00:00:00 2001 From: aspwil Date: Sun, 4 Apr 2021 06:18:34 -0600 Subject: [PATCH] fixed error caused by negative number for St instruction --- src/ndballsim/Parser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ndballsim/Parser.java b/src/ndballsim/Parser.java index 8372854..9667483 100644 --- a/src/ndballsim/Parser.java +++ b/src/ndballsim/Parser.java @@ -414,6 +414,9 @@ public static Instr[] parse(String file, boolean unlimit) { error(lineNum, "String instruction requires a ending \"]\" ex. St[num]"); } try { + if( Integer.parseInt(line.substring(3, line.length() - 1)) < 0){ + error(lineNum, "String instruction only accepts non-negative numbers"); + } list.add(new Instr(pos, "St", Integer.parseInt(line.substring(3, line.length() - 1)))); } catch (NumberFormatException e) { //was not a number