From fd67e95fe53acdc96c409ae0b1279df5ed546176 Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Mon, 13 Oct 2025 16:21:18 -0600 Subject: [PATCH 01/15] Added ASCII art to game launcher --- .idea/workspace.xml | 51 +++++++++++++++++++++++++++++++++++++++++++++ GameLauncher.java | 6 +++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..0ff23f0 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1760390460371 + + + + \ No newline at end of file diff --git a/GameLauncher.java b/GameLauncher.java index d8285c3..86560f3 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -96,7 +96,11 @@ private static List registerGames() { protected void run() { boolean running = true; while (running) { - System.out.println("\n=== Console Arcade Hub ==="); + System.out.println( +"/ \\__/|/ __// \\ /|/ \\ /\\\n" ++ "| |\\/||| \\ | |\\ ||| | ||\n" ++ "| | ||| /_ | | \\||| \\_/|\n" ++ "\\_/ \\|\\____\\\\_/ \\|\\____/"); for (int i = 0; i < this.games.size(); i++) { System.out.printf("%d. %s\n", i + 1, From eb6b4d5dbcd48f547d610e001a59be65006ce5ea Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 14 Oct 2025 07:50:01 -0600 Subject: [PATCH 02/15] Delete .idea directory Signed-off-by: Matt --- .idea/workspace.xml | 51 --------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 0ff23f0..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - 1760390460371 - - - - \ No newline at end of file From 734cbaa2a8dd6f278d13019636c67ad64b3578d1 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 14 Oct 2025 07:50:18 -0600 Subject: [PATCH 03/15] Update .gitignore Signed-off-by: Matt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6529974..44f1ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ history.dat reports/ doc/ +.idea/ # Java Section *.class From dcef9e23c0f098987daf3ffe277cbed574c7a1fc Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 14 Oct 2025 12:57:38 -0600 Subject: [PATCH 04/15] Update .gitignore Signed-off-by: Matt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6529974..44f1ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ history.dat reports/ doc/ +.idea/ # Java Section *.class From 8bb5490b3a3f11be272ceeb845a04a12bb5e02ec Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 14:54:27 -0600 Subject: [PATCH 05/15] Made text more readable --- GameLauncher.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/GameLauncher.java b/GameLauncher.java index 86560f3..dd7e109 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -96,11 +96,14 @@ private static List registerGames() { protected void run() { boolean running = true; while (running) { + System.out.println("\n=== Console Game Hub ===\n"); System.out.println( -"/ \\__/|/ __// \\ /|/ \\ /\\\n" -+ "| |\\/||| \\ | |\\ ||| | ||\n" -+ "| | ||| /_ | | \\||| \\_/|\n" -+ "\\_/ \\|\\____\\\\_/ \\|\\____/"); + " __ __ ___ _ _ _ _ \n" + + " | \\/ | __| \\| | | | |\n" + + " | |\\/| | _|| .` | |_| |\n" + + " |_| |_|___|_|\\_|\\___/ \n" + + " " + ); for (int i = 0; i < this.games.size(); i++) { System.out.printf("%d. %s\n", i + 1, From a2581d32e3d33270dde7886efa4b613375be9770 Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 15:14:49 -0600 Subject: [PATCH 06/15] Fixed to pass tests --- GameLauncher.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GameLauncher.java b/GameLauncher.java index dd7e109..3f1758d 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -98,11 +98,11 @@ protected void run() { while (running) { System.out.println("\n=== Console Game Hub ===\n"); System.out.println( - " __ __ ___ _ _ _ _ \n" + - " | \\/ | __| \\| | | | |\n" + - " | |\\/| | _|| .` | |_| |\n" + - " |_| |_|___|_|\\_|\\___/ \n" + - " " + " __ __ ___ _ _ _ _ \n" + ++ " | \\/ | __| \\| | | | |\n" ++ " | |\\/| | _|| .` | |_| |\n" ++ " |_| |_|___|_|\\_|\\___/ \n" ++ "\n" ); for (int i = 0; i < this.games.size(); i++) { System.out.printf("%d. %s\n", From 5fdb89a8e708ad7f1ec0ec1167e3074bccf9a4a3 Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 15:15:52 -0600 Subject: [PATCH 07/15] Fixed error --- GameLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameLauncher.java b/GameLauncher.java index 3f1758d..07f5270 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -98,7 +98,7 @@ protected void run() { while (running) { System.out.println("\n=== Console Game Hub ===\n"); System.out.println( - " __ __ ___ _ _ _ _ \n" + + " __ __ ___ _ _ _ _ \n" + " | \\/ | __| \\| | | | |\n" + " | |\\/| | _|| .` | |_| |\n" + " |_| |_|___|_|\\_|\\___/ \n" From e09e3e56b4c0bad91b1e0674217e0db7981cda3d Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 15:17:31 -0600 Subject: [PATCH 08/15] Fixed checkstyle errors --- GameLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameLauncher.java b/GameLauncher.java index 07f5270..8615ff1 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -98,7 +98,7 @@ protected void run() { while (running) { System.out.println("\n=== Console Game Hub ===\n"); System.out.println( - " __ __ ___ _ _ _ _ \n" +" __ __ ___ _ _ _ _ \n" + " | \\/ | __| \\| | | | |\n" + " | |\\/| | _|| .` | |_| |\n" + " |_| |_|___|_|\\_|\\___/ \n" From 119b4116a35ccef1c2cd870dc5c61b500e7894e9 Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 15:18:38 -0600 Subject: [PATCH 09/15] Fixed checkstyle errors --- GameLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameLauncher.java b/GameLauncher.java index 8615ff1..f827f11 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -96,7 +96,7 @@ private static List registerGames() { protected void run() { boolean running = true; while (running) { - System.out.println("\n=== Console Game Hub ===\n"); + System.out.println("=== Console Game Hub ===\n"); System.out.println( " __ __ ___ _ _ _ _ \n" + " | \\/ | __| \\| | | | |\n" From c20df095d8c155afbf559ef600a8eddac3078241 Mon Sep 17 00:00:00 2001 From: Matt Cantin Date: Wed, 15 Oct 2025 15:26:13 -0600 Subject: [PATCH 10/15] Fixed checkstyle errors --- GameLauncher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameLauncher.java b/GameLauncher.java index f827f11..400a65c 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -96,9 +96,9 @@ private static List registerGames() { protected void run() { boolean running = true; while (running) { - System.out.println("=== Console Game Hub ===\n"); System.out.println( -" __ __ ___ _ _ _ _ \n" +"=== Console Game Hub === \n" ++ " __ __ ___ _ _ _ _ \n" + " | \\/ | __| \\| | | | |\n" + " | |\\/| | _|| .` | |_| |\n" + " |_| |_|___|_|\\_|\\___/ \n" From 9de4ce236dc3f2627c781918715d8ac9663dc248 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 15 Oct 2025 15:28:19 -0600 Subject: [PATCH 11/15] Remove .idea from .gitignore Removed .idea directory from gitignore. Signed-off-by: Matt --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 44f1ce5..6529974 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ history.dat reports/ doc/ -.idea/ # Java Section *.class From c84426e54dcf74c9cc7082d682c399168d3c7158 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 15 Oct 2025 15:29:25 -0600 Subject: [PATCH 12/15] Revert "Fixed checkstyle errors" --- GameLauncher.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/GameLauncher.java b/GameLauncher.java index 400a65c..d8285c3 100644 --- a/GameLauncher.java +++ b/GameLauncher.java @@ -96,14 +96,7 @@ private static List registerGames() { protected void run() { boolean running = true; while (running) { - System.out.println( -"=== Console Game Hub === \n" -+ " __ __ ___ _ _ _ _ \n" -+ " | \\/ | __| \\| | | | |\n" -+ " | |\\/| | _|| .` | |_| |\n" -+ " |_| |_|___|_|\\_|\\___/ \n" -+ "\n" - ); + System.out.println("\n=== Console Arcade Hub ==="); for (int i = 0; i < this.games.size(); i++) { System.out.printf("%d. %s\n", i + 1, From 01924fda49fc643c944b06d2e703e485cd931baf Mon Sep 17 00:00:00 2001 From: Erik Thompson Date: Mon, 20 Oct 2025 15:45:49 -0600 Subject: [PATCH 13/15] user story 26 Added line to display the number of remaining guesses in Jotto --- JottoGame.java | 1 + 1 file changed, 1 insertion(+) diff --git a/JottoGame.java b/JottoGame.java index f08af55..ad490b0 100644 --- a/JottoGame.java +++ b/JottoGame.java @@ -62,6 +62,7 @@ public Optional play() { int attemptsLeft = MAX_GUESSES; while (attemptsLeft > 0) { + System.out.println("You have " + attemptsLeft + " guesses remaining."); System.out.print("Enter guess: "); String guess = scanner.nextLine().trim().toUpperCase(); From 409a24369fc1b4b907789292951d25047e2f838d Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 22 Oct 2025 15:11:40 -0600 Subject: [PATCH 14/15] Revert Jotto in main branch Removed a line that prints the number of guesses remaining. Signed-off-by: Matt --- JottoGame.java | 1 - 1 file changed, 1 deletion(-) diff --git a/JottoGame.java b/JottoGame.java index ad490b0..f08af55 100644 --- a/JottoGame.java +++ b/JottoGame.java @@ -62,7 +62,6 @@ public Optional play() { int attemptsLeft = MAX_GUESSES; while (attemptsLeft > 0) { - System.out.println("You have " + attemptsLeft + " guesses remaining."); System.out.print("Enter guess: "); String guess = scanner.nextLine().trim().toUpperCase(); From 562745771c40472f6027a8a31986d124a6bd1760 Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 27 Oct 2025 03:04:23 +0000 Subject: [PATCH 15/15] 33 Signed-off-by: Drew --- GameHistoryTracker.java | 81 ++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/GameHistoryTracker.java b/GameHistoryTracker.java index ffd810e..208b9d9 100644 --- a/GameHistoryTracker.java +++ b/GameHistoryTracker.java @@ -7,6 +7,8 @@ import java.io.ObjectOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; /** * Track history and stats of games played. @@ -14,8 +16,9 @@ * @author Cesar Soto, Mason Proctor, Luke Ross * @version 2 */ -class GameHistoryTracker implements Serializable { - private static final long serialVersionUID = 2L; +public class GameHistoryTracker implements Serializable { + private static final long serialVersionUID = 5L; + /** Collection of play stats for each game. */ private final HashMap statsMap = new HashMap<>(); @@ -27,15 +30,18 @@ class GameHistoryTracker implements Serializable { public void recordPlay(final String gameName, final Integer score) { GameStats stats = statsMap.getOrDefault(gameName, new GameStats()); stats.incrementTimesPlayed(); + if (score != null) { - stats.totalScore += score; - stats.scores.add(score); + stats.addScore(score); // adds score AND updates lastPlayed + } else { + stats.updateLastPlayed(); // update timestamp even if no score } + statsMap.put(gameName, stats); } /** - * Displays a summary of play history and scores. + * Displays a summary of play history, showing average score, last score, and last played timestamp. */ public void displayHistory() { System.out.println("\n=== Game Play History ==="); @@ -43,14 +49,19 @@ public void displayHistory() { System.out.println("No games played yet."); return; } + for (Map.Entry entry : statsMap.entrySet()) { String game = entry.getKey(); GameStats stats = entry.getValue(); System.out.printf("%s - Played: %d", game, stats.timesPlayed); + if (!stats.scores.isEmpty()) { - double avg = stats.totalScore / (double) stats.scores.size(); - System.out.printf(", Avg Score: %.2f", avg); + double avg = stats.getAverageScore(); + int lastScore = stats.getLastScore(); + System.out.printf(", Avg Score: %.2f, Last Score: %d", avg, lastScore); } + + System.out.printf(", Last Played: %s", stats.getLastPlayedFormatted()); System.out.println(); } } @@ -61,8 +72,7 @@ public void displayHistory() { * @throws IOException if an I/O error occurs */ public void saveHistory(final String filename) throws IOException { - try (ObjectOutputStream out = - new ObjectOutputStream(new FileOutputStream(filename))) { + try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename))) { out.writeObject(this); } } @@ -83,15 +93,13 @@ public void clearHistory(final String filename) { /** * Loads the game history from a file. * @param filename the name of the file to load from - * @return useful game history tracker + * @return a GameHistoryTracker instance */ public static GameHistoryTracker loadHistory(final String filename) { - try (ObjectInputStream in - = new ObjectInputStream(new FileInputStream(filename))) { + try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(filename))) { return (GameHistoryTracker) in.readObject(); } catch (IOException | ClassNotFoundException e) { - System.err.println( - "No previous history found or failed to load. Starting fresh."); + System.err.println("No previous history found or failed to load. Starting fresh."); return new GameHistoryTracker(); } } @@ -100,25 +108,40 @@ public static GameHistoryTracker loadHistory(final String filename) { * Inner class to track stats for a single game. */ private static class GameStats implements Serializable { - private static final long serialVersionUID = 2L; - /** The number of times game has been played. */ + private static final long serialVersionUID = 5L; + private int timesPlayed = 0; - /** The current total score. */ private int totalScore = 0; - /** All recorded scores. */ private ArrayList scores = new ArrayList<>(); - /** - * Access the number of times the game has been played. - * @return times played - */ - int getTimesPlayed() { - return this.timesPlayed; + private long lastPlayed = 0; + + int getTimesPlayed() { return this.timesPlayed; } + void incrementTimesPlayed() { this.timesPlayed++; } + + void addScore(int score) { + scores.add(score); + totalScore += score; + updateLastPlayed(); + } + + int getLastScore() { + if (scores.isEmpty()) return 0; + return scores.get(scores.size() - 1); + } + + double getAverageScore() { + if (scores.isEmpty()) return 0; + return totalScore / (double) scores.size(); + } + + void updateLastPlayed() { + this.lastPlayed = System.currentTimeMillis(); } - /** - * Increment the number of times the game has been played. - */ - void incrementTimesPlayed() { - this.timesPlayed++; + + String getLastPlayedFormatted() { + if (lastPlayed == 0) return "Never"; + SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy – h:mm a"); + return sdf.format(new Date(lastPlayed)); } } }