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,40 +108,55 @@ public class UI {
|
||||||
* let the robots sort
|
* let the robots sort
|
||||||
*/
|
*/
|
||||||
private void useRobot(){
|
private void useRobot(){
|
||||||
System.out.println("Welchen Roboter wollen Sie verwenden");
|
String[] listOfAll = fs.getAllRobots();
|
||||||
listAllRobots();
|
if(listOfAll.length > 0){
|
||||||
System.out.print(" ID > ");
|
System.out.println("Welchen Roboter wollen Sie verwenden");
|
||||||
int idInput = Integer.parseInt(sc.nextLine());
|
listAllRobots();
|
||||||
// Change the searchForRobot Methode (safety)
|
System.out.print(" ID > ");
|
||||||
Robot r = fs.searchForRobot(idInput);
|
int idInput = Integer.parseInt(sc.nextLine());
|
||||||
System.out.println("Du hast " + r.getName() + " gewählt der vom Typ " + r.getType() + " ist");
|
System.out.println("Du hast " + fs.searchForRobot(idInput).getName() + " gewählt der vom Typ " + fs.searchForRobot(idInput).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("-2- -- Sortieren einer Liste --");
|
System.out.println("-1- --- Roboter Ausschalten ---");
|
||||||
System.out.println("-3- ---------- Exit -----------");
|
if(!fs.searchForRobot(idInput).isPowerOn())
|
||||||
System.out.print(" > ");
|
System.out.println("-1- --- Roboter Ausschalten ---");
|
||||||
//User options
|
System.out.println("-2- -- Sortieren einer Liste --");
|
||||||
try {
|
System.out.println("-3- ---------- Exit -----------");
|
||||||
int input = Integer.parseInt(sc.nextLine());
|
System.out.print(" > ");
|
||||||
switch (input) {
|
//User options
|
||||||
case 1:
|
try {
|
||||||
listAllRobots();
|
int input = Integer.parseInt(sc.nextLine());
|
||||||
break;
|
switch (input) {
|
||||||
case 2:
|
case 1:
|
||||||
buildNewRobot();
|
fs.searchForRobot(idInput).triggerPowerSwitch();
|
||||||
break;
|
System.out.println("Der Roboter hat seinen Zustand gewechselt");
|
||||||
case 3:
|
break;
|
||||||
break;
|
case 2:
|
||||||
default:
|
int[] unsortedList = null;
|
||||||
System.out.println("Keine valide Option auswahl"); break;
|
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;
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Keine valide Option auswahl"); break;
|
||||||
|
}
|
||||||
|
}catch(NumberFormatException | RobotException e) {
|
||||||
|
System.out.println("Kein valider Input");
|
||||||
}
|
}
|
||||||
}catch(NumberFormatException e) {
|
|
||||||
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