Factory roboterBauen() User bringt das Programm durch flasche eingaben
zum einsturz.master
parent
38ca80a937
commit
32e22a1b48
|
@ -2,6 +2,9 @@ package ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import javax.management.loading.PrivateClassLoader;
|
||||||
|
|
||||||
import facade.Factorysystem;
|
import facade.Factorysystem;
|
||||||
import tpe.exceptions.roboter.exceptions.RobotException;
|
import tpe.exceptions.roboter.exceptions.RobotException;
|
||||||
|
|
||||||
|
@ -20,7 +23,6 @@ public class Factory {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("========");
|
System.out.println("========");
|
||||||
System.out.println("Factory Hauptmenü");
|
System.out.println("Factory Hauptmenü");
|
||||||
System.out.println("0 -> Alle Roboter anzeigen");
|
|
||||||
System.out.println("1 -> Roboter bauen");
|
System.out.println("1 -> Roboter bauen");
|
||||||
System.out.println("2 -> Roboter auswählen");
|
System.out.println("2 -> Roboter auswählen");
|
||||||
System.out.println("9 -> Beenden");
|
System.out.println("9 -> Beenden");
|
||||||
|
@ -31,9 +33,6 @@ public class Factory {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
switch (input) {
|
switch (input) {
|
||||||
case 0:
|
|
||||||
roboterAnzeigen();
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
roboterBauen();
|
roboterBauen();
|
||||||
break;
|
break;
|
||||||
|
@ -50,16 +49,24 @@ public class Factory {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void roboterAnzeigen() {
|
private void roboterBauen() {
|
||||||
|
int auswahl;
|
||||||
|
String name;
|
||||||
|
while(true) {
|
||||||
|
try {
|
||||||
|
System.out.println("Welchen Robotertyp möchten Sie haben?(R2D2(1) oder C3PO (2)");
|
||||||
|
auswahl = Integer.parseInt(sc.nextLine());
|
||||||
|
if (auswahl == 1 || auswahl == 2) break;
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.out.println("Bitte 1 oder 2 eingeben");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void roboterBauen() {
|
while(true) {
|
||||||
System.out.println("Welchen Robotertyp möchten Sie haben?(R2D2(1) oder C3PO (2)");
|
|
||||||
int auswahl = Integer.parseInt(sc.nextLine());
|
|
||||||
|
|
||||||
System.out.println("Wie wollen Sie ihren Roboter nennen?");
|
System.out.println("Wie wollen Sie ihren Roboter nennen?");
|
||||||
String name = sc.nextLine();
|
name = sc.nextLine();
|
||||||
|
if (!name.isBlank())break;
|
||||||
|
}
|
||||||
|
|
||||||
int seriennummer = factorysystem.roboterAnlegen(name, auswahl);
|
int seriennummer = factorysystem.roboterAnlegen(name, auswahl);
|
||||||
System.out.println(name + " mit der Seriennummer: " + seriennummer + " wurde erstellt.");
|
System.out.println(name + " mit der Seriennummer: " + seriennummer + " wurde erstellt.");
|
||||||
|
|
|
@ -13,11 +13,11 @@ class FactoryTest {
|
||||||
private static Factorysystem fs;
|
private static Factorysystem fs;
|
||||||
private static Factory factory;
|
private static Factory factory;
|
||||||
|
|
||||||
@BeforeAll
|
/*@BeforeAll
|
||||||
static void initFactory() throws RobotException {
|
static void initFactory() throws RobotException {
|
||||||
//Factorysystem fs = new Factorysystem ("Robot Fabrik");
|
//Factorysystem fs = new Factorysystem ("Robot Fabrik");
|
||||||
//Factory factory = new Factory(fs);
|
//Factory factory = new Factory(fs);
|
||||||
}
|
}*/
|
||||||
/*@Test
|
/*@Test
|
||||||
void smoketest() {
|
void smoketest() {
|
||||||
assertNull(fs);
|
assertNull(fs);
|
||||||
|
@ -25,7 +25,11 @@ class FactoryTest {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
static void alleRoboterAnzeigenTest() {
|
static void hauptmenüTest() throws RobotException{
|
||||||
|
Factorysystem fs = new Factorysystem ("Robot Fabrik");
|
||||||
|
Factory ui = new Factory (fs);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue