diff --git a/command-terminal/commandTerm.jar b/command-terminal/commandTerm.jar index 5b9dddf..562e7b4 100644 Binary files a/command-terminal/commandTerm.jar and b/command-terminal/commandTerm.jar differ diff --git a/command-terminal/src/ControlTerminal/ControlTerminal.java b/command-terminal/src/ControlTerminal/ControlTerminal.java index b0f1765..fea2a93 100644 --- a/command-terminal/src/ControlTerminal/ControlTerminal.java +++ b/command-terminal/src/ControlTerminal/ControlTerminal.java @@ -125,35 +125,55 @@ public class ControlTerminal { socket.send(p); System.out.println("Request sent, waiting for response"); - }else{ + }else if(input.equals("u")){ System.out.println("Please enter plane number"); - planeNumber = s.nextInt(); - keys = new ArrayList(container.getMap().keySet()); - plane = container.getMap().get(keys.get(planeNumber-1)); + try{ + planeNumber = s.nextInt(); + }catch(Exception e){ + System.out.println("Wrong input please retry"); + s.nextLine(); + continue; + } + + try{ + keys = new ArrayList(container.getMap().keySet()); + plane = container.getMap().get(keys.get(planeNumber-1)); + }catch(Exception e){ + System.out.println("Unknown plane please retry"); + s.nextLine(); + continue; + } flags = 0x01; while(true){ System.out.println("Enter the information you want to update (1: alt,2:cap,3:speed)"); - data = s.nextInt(); - switch(data){ - case 1: - System.out.println("Enter the new altitude"); - data = s.nextInt(); - plane.setZ(data); - flags = (byte) (flags|0x08); - break; - case 2: - System.out.println("Enter the new cap"); - data = s.nextInt(); - plane.setCap(data); - flags = (byte) (flags|0x02); - break; - case 3: - System.out.println("Enter the new speed"); - data = s.nextInt(); - plane.setSpeed(data); - flags = (byte) (flags|0x04); - break; - } + try{ + data = s.nextInt(); + switch(data){ + case 1: + System.out.println("Enter the new altitude"); + data = s.nextInt(); + plane.setZ(data); + flags = (byte) (flags|0x08); + break; + case 2: + System.out.println("Enter the new cap"); + data = s.nextInt(); + plane.setCap(data); + flags = (byte) (flags|0x02); + break; + case 3: + System.out.println("Enter the new speed"); + data = s.nextInt(); + plane.setSpeed(data); + flags = (byte) (flags|0x04); + break; + } + }catch(Exception e){ + System.out.println("Wrong input please retry"); + s.nextLine(); + continue; + + } System.out.println("Do you want to update more data on this plane (y/n)"); if(s.next().equals("n")){ @@ -168,6 +188,8 @@ public class ControlTerminal { socket.send(p); System.out.println("Request sent, waiting for response"); s.nextLine(); + }else{ + System.out.println("Unknown command, please retry"); } }