110 lines
2.6 KiB
Java
110 lines
2.6 KiB
Java
import java.util.Scanner;
|
|
|
|
|
|
public class BattleshipMain{
|
|
|
|
|
|
public static void main(String[] args){
|
|
|
|
|
|
Scanner sc = new Scanner(System.in); //Scanner
|
|
|
|
|
|
|
|
|
|
System.out.println("\n\t\t\tBATTLESHIP GALACTICA\n\n");
|
|
|
|
|
|
Battleship game = new Battleship();
|
|
|
|
int spalte = 0, s1 = 0, s2 = 0; //Schleife Schiffe platzierem
|
|
char zeile = 'a';
|
|
boolean horiz = false;
|
|
|
|
//Schiffe Platzieren
|
|
|
|
|
|
while (s2 < 10){
|
|
|
|
for (Battleship.Ship s : Battleship.Ship.values()){
|
|
|
|
System.out.printf("\n\t\t PLACE YOUR SHIPS: \n\n%dx Kreuzer\t%dx Fregatte\t%dx Yacht\t%dx Speedboat\n", Battleship.Ship.Kreuzer.getCount(), Battleship.Ship.Fregatte.getCount(), Battleship.Ship.Yacht.getCount(), Battleship.Ship.Speedboat.getCount());
|
|
|
|
|
|
/*while (s1 < 1){
|
|
System.out.println("\nSchiffsart: 1. Kreuzer 2. Freagtte 3. Yacht 4. Speedboat");
|
|
art = sc.nextInt();
|
|
if (art < 5 && art > 0){s1++;}
|
|
else{System.out.print("Falsche Eingabe!\n");}
|
|
}
|
|
//Schleifenreset
|
|
s1 = 0;*/
|
|
boolean platziert = false;
|
|
|
|
|
|
System.out.println("\nSchiffsart: " + s + "\nSize: " + s.getSize() + "\nAnzahl: " +s.getCount() );
|
|
|
|
while (!platziert){
|
|
|
|
while (s1 < 1){
|
|
System.out.println("Zeile (a-j): ");
|
|
zeile =sc.next().toLowerCase().charAt(0);
|
|
if (zeile < 107 && zeile > 96){s1++;}
|
|
else{System.out.print("Falsche Eingabe!\n");}
|
|
}
|
|
|
|
while (s1 < 2){
|
|
System.out.println("Spalte 1-10: ");
|
|
spalte = sc.nextInt();
|
|
if (spalte < 11 && spalte > 0){s1++;}
|
|
else{System.out.print("Falsche Eingabe!\n");}
|
|
}
|
|
|
|
while (s1 < 3){
|
|
System.out.println("Horizontal? (true/false): ");
|
|
horiz = sc.nextBoolean();
|
|
if (horiz == true || horiz == false) {s1++;}
|
|
else{System.out.print("Falsche Eingabe!\n");}
|
|
}
|
|
if (game.canPlace(s, zeile, spalte, horiz)) {
|
|
game.place(s, zeile, spalte, horiz);
|
|
platziert = true; // raus aus der while
|
|
game.ausgabe();
|
|
s2++;
|
|
s.redCount();
|
|
}
|
|
else {
|
|
System.out.println("Platzieren nicht möglich, andere Position wählen.");
|
|
|
|
}
|
|
|
|
s1 = 0;
|
|
|
|
|
|
}
|
|
}
|
|
/*if(art == 1 && Battleship.Ship.Kreuzer.getCount() > 0){
|
|
game.place(Battleship.Ship.Kreuzer, zeile, spalte, horiz);
|
|
}
|
|
|
|
else if(art == 2 && Battleship.Ship.Fregatte.getCount() > 0){
|
|
game.place(Battleship.Ship.Fregatte, zeile, spalte, horiz);
|
|
}
|
|
|
|
else if(art == 3 && Battleship.Ship.Yacht.getCount() > 0){
|
|
game.place(Battleship.Ship.Yacht, zeile, spalte, horiz);
|
|
}
|
|
|
|
else if(art == 4 && Battleship.Ship.Speedboat.getCount() > 0){
|
|
game.place(Battleship.Ship.Speedboat, zeile, spalte, horiz);
|
|
}
|
|
|
|
else {System.out.print("\n\nDa passt was nicht, versuchs nochmal!\n\n");}
|
|
game.ausgabe();
|
|
*/
|
|
|
|
}
|
|
//sc.close();
|
|
}
|
|
}
|