示例#1
0
  private static void updateStatus() {
    Random generator = new Random();
    int accidente1 = generator.nextInt(2);
    // System.out.println("" + accidente1);
    int accidente2 = generator.nextInt(2);
    // System.out.println("" + accidente2);
    int accidente3 = generator.nextInt(2);
    // System.out.println(""+ accidente3);

    if (accidente1 == 1) {
      coche1.setActive(false);
      System.out.println("Accidente Coche 1");
    } else {
      coche1.setActive(true);
      System.out.println("Reparación Coche 1");
    }

    if (accidente2 == 1) {
      coche2.setActive(false);
      System.out.println("Accidente Coche 2");
    } else {
      coche2.setActive(true);
      System.out.println("Reparación Coche 2");
    }

    if (accidente3 == 1) {
      coche3.setActive(false);
      System.out.println("Accidente Coche 3");
    } else {
      coche3.setActive(true);
      System.out.println("Reparación Coche 3");
    }
  }