예제 #1
0
  public static void main(String[] args) {
    int nAttacks = 0;
    Porto porto = new Porto();
    porto.setNome("P2");
    porto.setnImbarcazioni(15);
    porto.setDimensioneSqMeters(500);

    Sottomarino s = new Sottomarino();
    s.setId("s1");
    s.setModello("fighter");
    s.setStazza(30);
    s.setnArmamenti(5);
    Aereo a = new Aereo();
    a.setId("a1");
    a.setModello("falker");
    a.setnArmamentiAlpha(5);
    a.setnArmamentiBeta(2);

    Invasore[] invasori = new Invasore[] {s, a};

    Gioco g = new Gioco(porto);
    while (!g.portoDistrutto()) {
      g.attacco(invasori);
      nAttacks++;
    }

    System.out.println(nAttacks);
  }
예제 #2
0
  public static void main(String args[]) {
    PortoNavale porto = new PortoNavale(30000);
    Gioco partita = new Gioco(porto);

    Aereo rosso = new Aereo(1, "red", 3, 6); // 180 dmg
    Aereo blu = new Aereo(2, "blue", 1, 2); // 60 dmg
    Aereo verde = new Aereo(3, "green", 2, 7); // 195 dmg
    Aereo giallo = new Aereo(4, "yellow", 7, 11); // 345 dmg

    Sottomarino oro = new Sottomarino(1, "gold", 20, 10); // 200
    Sottomarino argento = new Sottomarino(1, "silver", 20, 10); // 200
    Sottomarino cristallo = new Sottomarino(1, "crystal", 20, 10); // 200
    // tot = 1380
    // 30000/1380 = 22

    Invasore[] invasori = {rosso, blu, verde, giallo, oro, argento, cristallo};

    int turni = 0;
    do {
      turni += partita.attaccaPorto(invasori);
    } while (!partita.isDestroyed());
    System.out.println(turni);
  }