예제 #1
0
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    EnumMap<PlayerStats, Float> enumMap = new EnumMap<PlayerStats, Float>(PlayerStats.class);
    for (PlayerStats a : PlayerStats.values())
      if (!enumMap.containsKey(a)) enumMap.put(a, Float.NaN);

    String input;
    System.out.println(MENU);
    do {
      input = scanner.next().toLowerCase();
      switch (input) {
        case "print":
          printMap(enumMap);
          break;
        case "menu":
          System.out.println(MENU);
          break;
        case "load":
          System.out.print("Type in the file to load: ");
          EnumMap<PlayerStats, Float> loadedMap = DataLoader.loadPlayerObject(scanner.next());
          if (loadedMap == null) {
            System.out.println("Cannot load this file!");
            break;
          }
          enumMap = loadedMap;
          break;
        case "save":
          System.out.print("Type in the file to save to: ");
          saveData(scanner.next(), enumMap, true);
          break;
        case "iterate":
          iterateAll(scanner, enumMap);
          break;
        case "edit":
          System.out.print("Type in the property: ");
          input = scanner.next();
          PlayerStats playerStats = PlayerStats.valueOf(input);
          if (playerStats == null) System.out.println(input + " is not a property");
          else {
            System.out.print("Type in the value");
            processInput(enumMap, playerStats, scanner.next());
          }
          break;
        case "exit":
          break;
        default:
          System.out.println("You typed in an invalid menu option\n" + MENU);
          break;
      }
    } while (!input.equals("exit"));
  }
 public void parsePlayer() {
   String playerFile = getPlayerFile();
   if (playerFile != null) {
     playerStats = DataLoader.loadPlayerIni(playerFile);
   }
 }