first draft + methode für eingabe
parent
09d7536d36
commit
f47b3a3ed7
|
@ -7,6 +7,16 @@ public class Schachbrett {
|
||||||
public Schachbrett() {
|
public Schachbrett() {
|
||||||
felder = new String[][] {{"A","B","C","D","E","F","G","H"},{"1","2","3","4","5","6","7","8"}};
|
felder = new String[][] {{"A","B","C","D","E","F","G","H"},{"1","2","3","4","5","6","7","8"}};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int gueltigeEingabe(Scanner in, String achse) {
|
||||||
|
int zahl = 0;
|
||||||
|
do {
|
||||||
|
System.out.println("Position auf " + achse + " Achse: ");
|
||||||
|
zahl = in.nextInt();
|
||||||
|
} while (istEingabeUngueltig(zahl));
|
||||||
|
|
||||||
|
return zahl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean istEingabeUngueltig(int Zahl) {
|
public static boolean istEingabeUngueltig(int Zahl) {
|
||||||
|
@ -26,19 +36,8 @@ public class Schachbrett {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner in = new Scanner(System.in);
|
Scanner in = new Scanner(System.in);
|
||||||
int x = 0;
|
int x = gueltigeEingabe(in, "x");
|
||||||
int y = 0;
|
int y = gueltigeEingabe(in, "y");
|
||||||
|
|
||||||
do {
|
|
||||||
System.out.println("Position auf x Achse: ");
|
|
||||||
x = in.nextInt();
|
|
||||||
} while (istEingabeUngueltig(x));
|
|
||||||
|
|
||||||
do {
|
|
||||||
System.out.println("Position auf y Achse: ");
|
|
||||||
y = in.nextInt();
|
|
||||||
} while (istEingabeUngueltig(y));
|
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
Schachbrett instanz = new Schachbrett();
|
Schachbrett instanz = new Schachbrett();
|
||||||
|
|
Loading…
Reference in New Issue