javadocs for hockeystats and playerlist

This commit is contained in:
CT
2026-05-06 22:20:46 -05:00
parent 02494bdff0
commit d7bc53caa8
2 changed files with 98 additions and 3 deletions

View File

@@ -1,3 +1,11 @@
/**
* HockeyStats.java
*
* <p>The main driver class for the Hockey Stats Manager. Handles user input, file I/O operations,
* and menu navigation.
*
* @author Cody Trainer
*/
import java.io.*;
import java.util.*;
@@ -7,14 +15,25 @@ public class HockeyStats {
static StringTokenizer st;
static Scanner s = new Scanner(System.in);
/**
* Runs the primary menu loop.
*
* @param args Command line arguments (not used).
* @throws Exception If file reading or input errors occur.
*/
public static void main(String[] args) throws Exception {
while (true) {
if (showMenu()) break;
}
s.close();
}
/**
* Loads player data from a specified text file.
*
* @param fileName The name of the file to load from.
* @throws Exception If the file is not found or is improperly formatted.
*/
public static void loadData(String fileName) throws Exception {
players.clear();
File f = new File(fileName);
@@ -34,6 +53,12 @@ public class HockeyStats {
br.close();
}
/**
* Saves current player list data to a specified text file.
*
* @param fileName The name of the file to save to.
* @throws Exception If an I/O error occurs.
*/
public static void saveData(String fileName) throws Exception {
FileWriter fw = new FileWriter(fileName);
String save = players.createSaveData();
@@ -42,6 +67,12 @@ public class HockeyStats {
System.out.println("Data saved to " + fileName);
}
/**
* Displays the main menu and routes user to various sub-menus or actions.
*
* @return true if the user chooses to quit, false otherwise.
* @throws Exception If input errors occur.
*/
public static boolean showMenu() throws Exception {
System.out.print(
"""
@@ -95,6 +126,12 @@ public class HockeyStats {
return close;
}
/**
* Displays the editor menu for adding, removing, or updating player data.
*
* @return true if the user chooses to return to the main menu, false otherwise.
* @throws Exception If input errors occur.
*/
public static boolean showDataMenu() throws Exception {
System.out.print(
"""
@@ -176,6 +213,11 @@ public class HockeyStats {
return dataExit;
}
/**
* Displays the viewer menu for printing, finding, and sorting player statistics.
*
* @return true if the user chooses to return to the main menu, false otherwise.
*/
public static boolean showStatsMenu() {
System.out.print(
"""