import java.io.*; import java.util.*; public class HockeyStats { static PlayerList players = new PlayerList(); static BufferedReader br; static StringTokenizer st; public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); boolean close = false; while (true) { showMenu(); int n = s.nextInt(); switch (n) { case 1: loadData("data.txt"); break; case 2: showDataMenu(); int k = s.nextInt(); switch (k) { case 1: System.out.println(players.toString()); case 2: saveData("save.txt"); case 3: break; case 4: break; default: System.out.println("Please choose one of the available menu options!"); break; } break; case 3: showStatsMenu(); int t = s.nextInt(); switch (t) { default: break; } break; case 4: System.out.println("Thank you!"); System.exit(0); default: System.out.println("Please choose one of the available menu options!"); continue; } if (close) break; } s.close(); } public static void loadData(String fileName) throws Exception { File f = new File(fileName); br = new BufferedReader(new FileReader(f)); st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); for (int i = 0; i < n; i++) { st = new StringTokenizer(br.readLine()); players.addPlayer( new HockeyPlayer( st.nextToken() + " " + st.nextToken(), // first + last name Integer.parseInt(st.nextToken()), // goals Integer.parseInt(st.nextToken()), // assists Integer.parseInt(st.nextToken()), // gamesWon Integer.parseInt(st.nextToken()))); // gamesLost } } public static void saveData(String fileName) throws Exception { FileWriter fw = new FileWriter(fileName); String s = players.createSaveData(); fw.write(s); fw.close(); } public static void showMenu() { System.out.print( """ <----------------------------> Hockey Stats Manager Menu Select an option: (1) Load Data from Files (2) Open Data Editor (3) Open Stats View Menu (4) Quit <----------------------------> """); } public static void showDataMenu() { System.out.print( """ <----------------------------> Hockey Data Editor Menu Select an option: (1) Print Data (2) Save Data (3) null (4) Quit <----------------------------> """); } public static void showStatsMenu() {} }