diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Main.java b/Main.java deleted file mode 100644 index 023cd66..0000000 --- a/Main.java +++ /dev/null @@ -1,69 +0,0 @@ -import src.facade.FactorySystem; -import src.ui.UI; - -public class Main { - public static void main(String[] args) { - FactorySystem fs = new FactorySystem("test_factory"); - - UI ui = new UI(fs); - -// int[] input = {42,6,5,4,3,43,1}; -// int[] input2 = input; -// C3PO Herbert = new C3PO(1, "Herbert"); -// R2D2 Herb = new R2D2(0, "Herb"); -// int[] input3 = {}; -// -// //Herbert.triggerPowerSwitch(); -//// Herb.triggerPowerSwitch(); -// -// -//// try{ -//// String sorted = Herb.speak(input); -//// System.out.println(sorted); -//// } catch (RobotException re) { -//// System.out.println(re); -//// } -// -// try{ -// int[] sorted = Herb.think(input); -// for(int i = 0; i < sorted.length; i++){ -// System.out.print(" " + sorted[i]); -// } -// }catch(RobotException re){ -// re.printStackTrace(); -// } -// -// System.out.println("last exception thrown"); -// String re = Herb.getLastException().toString(); -// System.out.println(re); -// -// Herb.triggerPowerSwitch(); -// -// try{ -// int[] sorted = Herb.think(input); -// for(int i = 0; i < sorted.length; i++){ -// System.out.print(" " + sorted[i]); -// } -// }catch(RobotException e){ -// e.getLocalizedMessage(); -// } -// System.out.println("last exception thrown"); -// re = Herb.getLastException().toString(); -// System.out.println(re); -// -// //System.out.println("Was neues ausgeben"); -// -// //just some testing -// /*C3PO Herbert = new C3PO(0, "Herbert"); -// int[] input = {6,5,4,3,2,1}; -// Herbert.triggerPowerSwitch(); -// try{ -// String asString = Herbert.speak(input); -// System.out.println(asString); -// }catch(RobotException re){ -// System.out.println(re); -// } -// -// */ - } -} diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..8d21aa5 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,11 @@ +import facade.FactorySystem; +import ui.UI; + +public class Main { + public static void main(String[] args) { + FactorySystem fs = new FactorySystem("test_factory"); + + UI ui = new UI(fs); + } + +} diff --git a/src/ui/UI.java b/src/ui/UI.java index 217f5ce..b449158 100644 --- a/src/ui/UI.java +++ b/src/ui/UI.java @@ -120,10 +120,7 @@ public class UI { System.out.println(); System.out.println("_______________________________"); System.out.println("Sie haben folgende optionen: "); - if(fs.searchForRobot(idInput).isPowerOn()) - System.out.println("-1- --- Roboter Ausschalten ---"); - if(!fs.searchForRobot(idInput).isPowerOn()) - System.out.println("-1- --- Roboter Ausschalten ---"); + System.out.println("-1- --- Roboter " + (!fs.searchForRobot(idInput).isPowerOn() ? "Einschalten " : "Ausschalten " ) + " ---"); System.out.println("-2- -- Sortieren einer Liste --"); System.out.println("-3- ---------- Exit -----------"); System.out.print(" > "); @@ -140,21 +137,27 @@ public class UI { while(unsortedList == null) { try { unsortedList = fs.searchForRobot(idInput).think(Arrays.stream(sc.nextLine().split(", ")).mapToInt(Integer::parseInt).toArray()); - } catch (NumberFormatException nFE) { - System.out.println("Falsches Format versuch es erneut"); + System.out.println(fs.searchForRobot(idInput).speak(unsortedList)); + } catch (NumberFormatException | RobotException e) { + if(e.getClass() == RobotException.class){ + System.out.println(((RobotException) e).getMessage()); + break; + }else{ + System.out.println("Falsches Format versuch es erneut"); + break; + } } } - System.out.println(fs.searchForRobot(idInput).speak(unsortedList)); - break; - case 3: break; + case 3: break mainloop; default: - System.out.println("Keine valide Option auswahl"); break; + System.out.println("Keine valide Option"); break; } - }catch(NumberFormatException | RobotException e) { - System.out.println("Kein valider Input"); + }catch(NumberFormatException nfe) { + System.out.println("Kein valider input"); + } - } + } } else { System.out.println("Es wurden noch keine Roboter erzeugt"); } diff --git a/test_factoryFactory.ser b/test_factoryFactory.ser new file mode 100644 index 0000000..4972145 Binary files /dev/null and b/test_factoryFactory.ser differ