Expansion of the UI class
parent
08418fa66c
commit
683e5d9909
|
@ -4,6 +4,9 @@ import domain.Robot;
|
||||||
import domain.RobotType;
|
import domain.RobotType;
|
||||||
import facade.FactorySystem;
|
import facade.FactorySystem;
|
||||||
import infrastructure.Persistenz;
|
import infrastructure.Persistenz;
|
||||||
|
import utility.robot_exceptions.RobotException;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class UI {
|
public class UI {
|
||||||
|
@ -105,19 +108,22 @@ public class UI {
|
||||||
* let the robots sort
|
* let the robots sort
|
||||||
*/
|
*/
|
||||||
private void useRobot(){
|
private void useRobot(){
|
||||||
|
String[] listOfAll = fs.getAllRobots();
|
||||||
|
if(listOfAll.length > 0){
|
||||||
System.out.println("Welchen Roboter wollen Sie verwenden");
|
System.out.println("Welchen Roboter wollen Sie verwenden");
|
||||||
listAllRobots();
|
listAllRobots();
|
||||||
System.out.print(" ID > ");
|
System.out.print(" ID > ");
|
||||||
int idInput = Integer.parseInt(sc.nextLine());
|
int idInput = Integer.parseInt(sc.nextLine());
|
||||||
// Change the searchForRobot Methode (safety)
|
System.out.println("Du hast " + fs.searchForRobot(idInput).getName() + " gewählt der vom Typ " + fs.searchForRobot(idInput).getType() + " ist");
|
||||||
Robot r = fs.searchForRobot(idInput);
|
|
||||||
System.out.println("Du hast " + r.getName() + " gewählt der vom Typ " + r.getType() + " ist");
|
|
||||||
mainloop:
|
mainloop:
|
||||||
while(true) {
|
while(true) {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("_______________________________");
|
System.out.println("_______________________________");
|
||||||
System.out.println("Sie haben folgende optionen: ");
|
System.out.println("Sie haben folgende optionen: ");
|
||||||
System.out.println("-1- --- An oder Ausschalten ---");
|
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("-2- -- Sortieren einer Liste --");
|
System.out.println("-2- -- Sortieren einer Liste --");
|
||||||
System.out.println("-3- ---------- Exit -----------");
|
System.out.println("-3- ---------- Exit -----------");
|
||||||
System.out.print(" > ");
|
System.out.print(" > ");
|
||||||
|
@ -126,19 +132,31 @@ public class UI {
|
||||||
int input = Integer.parseInt(sc.nextLine());
|
int input = Integer.parseInt(sc.nextLine());
|
||||||
switch (input) {
|
switch (input) {
|
||||||
case 1:
|
case 1:
|
||||||
listAllRobots();
|
fs.searchForRobot(idInput).triggerPowerSwitch();
|
||||||
|
System.out.println("Der Roboter hat seinen Zustand gewechselt");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
buildNewRobot();
|
int[] unsortedList = null;
|
||||||
|
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));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Keine valide Option auswahl"); break;
|
System.out.println("Keine valide Option auswahl"); break;
|
||||||
}
|
}
|
||||||
}catch(NumberFormatException e) {
|
}catch(NumberFormatException | RobotException e) {
|
||||||
System.out.println("Kein valider Input");
|
System.out.println("Kein valider Input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Es wurden noch keine Roboter erzeugt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue