package blatt3; import java.util.Random; public class Game { public static void main(String[] args){ //Neues Spielfeld anlegen Field spiel = new MyField(15,10); int placed = 0; Random rnd = new Random(); //Drei Schiffe der Laenge 3 zufaellig auf dem Spielfeld plazieren while (placed<3){ try{ int x=rnd.nextInt(12); int y=rnd.nextInt(7); int dir = rnd.nextInt(2); spiel.placeShip(x,y,3,dir); placed++; } catch (Exception e) { } } //Spielfeld ausgeben System.out.println(spiel.toString()); while(!spiel.isFinished()){ try { //Koordinaten fuer die Bombe abfragen System.out.print("x: "); int x = Console.readInt(); System.out.print("y: "); int y = Console.readInt(); //Bombe legen spiel.placeBomb(x,y); //Konsole löschen Console.clear(); //Spielfeld ausgeben System.out.println(spiel.toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println("Gewonnen!!"); } }