Factory hat die methode idVergeben() bekommen.

master
nikow 2023-01-05 18:32:33 +01:00
parent 604fe74082
commit 4ec9407bfe
3 changed files with 53 additions and 26 deletions

View File

@ -7,15 +7,15 @@ import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
public class C3PO extends Roboter { public class C3PO extends Roboter {
String name; String name;
int id; int id;
static int idZähler = 10000; //static int idZähler = 10000;
RobotType robotType; RobotType robotType;
RobotException fehler; RobotException fehler;
C3PO(String name) { C3PO(String name, int id) {
super(name); super(name);
this.robotType = robotType.C3PO; this.robotType = robotType.C3PO;
this.id = idZähler; this.id = id;
idZähler++; //idZähler++;
} }
@Override @Override

View File

@ -9,15 +9,15 @@ import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
public class R2D2 extends Roboter { public class R2D2 extends Roboter {
private int id; private int id;
private static int idZähler = 0; //private static int idZähler = 0;
private RobotType robotType; private RobotType robotType;
RobotException fehler; RobotException fehler;
R2D2(String name) { R2D2(String name, int id) {
super(name); super(name);
this.robotType = RobotType.R2D2; this.robotType = RobotType.R2D2;
this.id = idZähler; this.id = id;
idZähler++; //idZähler++;
} }
@Override @Override

View File

@ -2,49 +2,76 @@ package ui;
import java.util.Scanner; import java.util.Scanner;
import Domäne.Roboter;
import java.util.Collection;
import java.util.HashMap;
import java.util.Random;
public class Factory { public class Factory {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
public HashMap<Integer, Roboter> roboterLager = new HashMap<>();
public Factory() { public Factory() {
hauptmenü(); hauptmenü();
} }
private void hauptmenü() {
private void hauptmenü() { mainloop: while (true) {
mainloop:
while (true) {
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("9 -> Beenden"); System.out.println("9 -> Beenden");
System.out.println(); System.out.println();
System.out.println("> "); System.out.println("> ");
int input = Integer.parseInt(sc.nextLine()); int input = Integer.parseInt(sc.nextLine());
System.out.println(); System.out.println();
try { try {
switch(input) { switch (input) {
case 1: roboterBauen(); case 0:
case 9: break mainloop; roboterAnzeigen();
} case 1:
roboterBauen();
case 9:
break mainloop;
}
} catch (Exception e) { } catch (Exception e) {
} }
System.out.println(); System.out.println();
}
}
private void roboterAnzeigen() {
}
private void roboterBauen() {
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?");
String name = sc.nextLine();
if(auswahl == 1) {
roboterLager.put(idVergeben(0, 9999), R2D2 roboter = new R2D2(name);
} else if(auswahl == 2) {
} }
}
}
private void roboterBauen() {
private int idVergeben(int min, int max) {
return 0;
}
}
} }