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;
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("Ü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));
boolean isExiting = false;
while(!isExiting) {
String[] input = br.readLine().split(" ");
switch (input[0]) {
case "loadMap":
tester.loadMap(input[1]);
break;
case "listPlayers":
System.out.println(tester.listPlayers());
break;
case "move":
tester.move(input[1]);
break;
case "boxLift":
System.out.println(tester.boxLift(input[1]));
break;
case "boxDrop":
System.out.println(tester.boxDrop(input[1]));
break;
case "shootONeillsGun":
tester.shootONeillsGun(input[1]);
break;
case "rotate":
tester.rotate(input[1], input[2]);
break;
case "listStargates":
System.out.println(tester.listStargates());
break;
case "runAllTests":
boolean testresult = tester.runAllTests();
if (testresult)
System.out.println("All tests successful!");
else
System.out.println("Tests failed!");
break;
case "exit":
isExiting = true;
break;
while (!isExiting) {
try {
String[] input = br.readLine().split(" ");
switch (input[0]) {
case "loadMap":
tester.loadMap(input[1]);
break;
case "listPlayers":
System.out.println(tester.listPlayers());
break;
case "move":
tester.move(input[1]);
break;
case "boxLift":
System.out.println(tester.boxLift(input[1]));
break;
case "boxDrop":
System.out.println(tester.boxDrop(input[1]));
break;
case "shootONeillsGun":
tester.shootONeillsGun(input[1]);
break;
case "rotate":
tester.rotate(input[1], input[2]);
break;
case "listStargates":
System.out.println(tester.listStargates());
break;
case "runAllTests":
boolean testresult = tester.runAllTests();
if (testresult)
System.out.println("All tests successful!");
else
System.out.println("Tests failed!");
break;
case "exit":
isExiting = true;
break;
}
} catch (Exception e) {
e.printStackTrace();
//TODO not so granular error handling
}
}
}
}