コード例 #1
0
ファイル: Main.java プロジェクト: henvic/programming-101
  private void create(Scanner input, BuildingManager manager, l2.Building.Main buildingMain) {
    Building building;

    building = buildingMain.configureBuilding(input, new Building(), new Unit());
    manager.addBuilding(building);
    System.out.println("Imóvel adicionado!\n");
  }
コード例 #2
0
ファイル: Main.java プロジェクト: henvic/programming-101
  private void update(Scanner input, BuildingManager manager, l2.Building.Main buildingMain) {
    int index;
    Building building;

    System.out.print("Índice do imóvel a modificar: ");

    index = input.nextInt();

    // not allowed to use Math.abs()
    if (index < 0) {
      index *= -1;
    }

    index -= 1;
    input.nextLine();

    if (index < 0
        || manager.getBuildings().length < index + 1
        || manager.getBuildings()[index] == null) {
      System.out.println("Imóvel não encontrado.");
      return;
    }

    building = buildingMain.configureBuilding(input, new Building(), new Unit());
    manager.replaceBuilding(index, building);
  }