Added error handling in Menu babylon stylez

This commit is contained in:
Bokros Bálint 2016-04-26 02:12:13 +02:00
parent 55940e42ae
commit 20dff9e8c6

View File

@ -7,8 +7,7 @@ import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
public class Menu { public class Menu {
public static void main(String[] args) throws IOException, InvocationTargetException, IllegalAccessException public static void main(String[] args) throws IOException, InvocationTargetException, IllegalAccessException {
{
System.out.println("Continuously Integrated Cica Projekt - Proto"); System.out.println("Continuously Integrated Cica Projekt - Proto");
System.out.println("Üdvözöllek a Babylon Simulator 2000 játékban! Kérlek válassz egy menüpontot!"); System.out.println("Üdvözöllek a Babylon Simulator 2000 játékban! Kérlek válassz egy menüpontot!");
@ -17,44 +16,50 @@ public class Menu {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
boolean isExiting = false; boolean isExiting = false;
while(!isExiting) { while (!isExiting) {
String[] input = br.readLine().split(" "); try {
switch (input[0]) { String[] input = br.readLine().split(" ");
case "loadMap": switch (input[0]) {
tester.loadMap(input[1]); case "loadMap":
break; tester.loadMap(input[1]);
case "listPlayers": break;
System.out.println(tester.listPlayers()); case "listPlayers":
break; System.out.println(tester.listPlayers());
case "move": break;
tester.move(input[1]); case "move":
break; tester.move(input[1]);
case "boxLift": break;
System.out.println(tester.boxLift(input[1])); case "boxLift":
break; System.out.println(tester.boxLift(input[1]));
case "boxDrop": break;
System.out.println(tester.boxDrop(input[1])); case "boxDrop":
break; System.out.println(tester.boxDrop(input[1]));
case "shootONeillsGun": break;
tester.shootONeillsGun(input[1]); case "shootONeillsGun":
break; tester.shootONeillsGun(input[1]);
case "rotate": break;
tester.rotate(input[1], input[2]); case "rotate":
break; tester.rotate(input[1], input[2]);
case "listStargates": break;
System.out.println(tester.listStargates()); case "listStargates":
break; System.out.println(tester.listStargates());
case "runAllTests": break;
boolean testresult = tester.runAllTests(); case "runAllTests":
if (testresult) boolean testresult = tester.runAllTests();
System.out.println("All tests successful!"); if (testresult)
else System.out.println("All tests successful!");
System.out.println("Tests failed!"); else
break; System.out.println("Tests failed!");
case "exit": break;
isExiting = true; case "exit":
break; isExiting = true;
break;
}
} catch (Exception e) {
e.printStackTrace();
//TODO not so granular error handling
} }
} }
} }
} }