Exemple #1
0
  public static boolean addHuman() throws IOException {
    // todo
    // add a human
    List<Object> objects = getData();
    List<Integer> rels = getRelation();
    System.out.println(" =========  Adding a Human ==============");
    int type =
        Integer.parseInt(Menu.generateQandAMenu(" - Human or Religious Human: press 3 or 4"));
    if (type != 3 && type != 4) return false;
    String name = Menu.generateQandAMenu(" - Type a name: ");
    int age = Integer.parseInt(Menu.generateQandAMenu(" - Type age: "));
    String city = Menu.generateQandAMenu(" - Type city: ");
    float money = (float) 10.0;
    int spirit = 100;
    if (type == 3) {
      objects.add(new Human(name, age, city, money, spirit, new HumanRank()));
      rels.add(type - 1);
    } else {
      objects.add(new Human(name, age, city, money, spirit, new ReligiousHumanRank()));
      rels.add(type - 1);
    }
    System.out.println(" ========= Human was added ==============");

    Menu.next();
    return true;
  }