From cbcbfb2a264480c67b32110c02e890825d7e866a Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 6 Oct 2025 22:57:49 -0400 Subject: Remove unused args parameter in Action --- src/main/java/design/controller/userinput/menus/HolePlayMenu.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/design/controller/userinput/menus/HolePlayMenu.java') diff --git a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java index bcd7560..e12bdfa 100644 --- a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java +++ b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java @@ -36,14 +36,14 @@ public class HolePlayMenu extends Menu { if (inSetup) { // 0) Start hole - opts.add(new MenuOption("start hole", (a) -> { + opts.add(new MenuOption("start hole", () -> { ctx.startHole(); System.out.println("Started hole " + round.getCurrentHole().getNumber() + "."); this.present(); })); } else { // 0) Take a shot - opts.add(new MenuOption("take a shot", (a) -> { + opts.add(new MenuOption("take a shot", () -> { // Gets club Scanner sc = new Scanner(System.in); System.out.print("Club nickname: "); @@ -68,7 +68,7 @@ public class HolePlayMenu extends Menu { })); // 1) Hole out - opts.add(new MenuOption("hole out", (a) -> { + opts.add(new MenuOption("hole out", () -> { // Precedes to next hole int prev = round.getCurrentHole().getNumber(); ctx.holeOut(); @@ -78,7 +78,7 @@ public class HolePlayMenu extends Menu { } // End round (always shown) - opts.add(new MenuOption("end round", (a) -> { + opts.add(new MenuOption("end round", () -> { ctx.endRoundNow(); System.out.println("Round ended."); new MainMenu().present(); -- cgit v1.2.3 From b50bce5a1c303e03cc50e1945de9c16cee044976 Mon Sep 17 00:00:00 2001 From: Michael Lizzio Date: Tue, 7 Oct 2025 13:14:41 -0400 Subject: Added AddClubMenu and modified club and golfer to allow club id's, added menu to UserSettings --- src/main/java/design/controller/userinput/menus/HolePlayMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/design/controller/userinput/menus/HolePlayMenu.java') diff --git a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java index e12bdfa..34e36f6 100644 --- a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java +++ b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java @@ -50,7 +50,7 @@ public class HolePlayMenu extends Menu { String nick = sc.nextLine().trim(); // Defaulted to Driver for now // TODO update logic - Club club = new Club("Generic", nick, Club.ClubType.DRIVER); + Club club = new Club(0, "Generic", nick, Club.ClubType.DRIVER); // Get shot distance (defaults to 0 of not stated) System.out.print("Distance (yds, blank=0): "); -- cgit v1.2.3 From a20f2f027981ce9c7677b969be24c962c0029907 Mon Sep 17 00:00:00 2001 From: Michael Lizzio Date: Tue, 7 Oct 2025 13:57:32 -0400 Subject: Updated HolePlayMenu to allow user to select one of their clubs --- .../controller/userinput/menus/HolePlayMenu.java | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'src/main/java/design/controller/userinput/menus/HolePlayMenu.java') diff --git a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java index 34e36f6..14e5345 100644 --- a/src/main/java/design/controller/userinput/menus/HolePlayMenu.java +++ b/src/main/java/design/controller/userinput/menus/HolePlayMenu.java @@ -44,13 +44,38 @@ public class HolePlayMenu extends Menu { } else { // 0) Take a shot opts.add(new MenuOption("take a shot", () -> { - // Gets club + // loads golfers clubs + var golfer = Session.getCurrentGolfer(); + Club[] clubs = (golfer == null) ? new Club[0] : golfer.getClubs(); + + if (clubs.length == 0) { + System.out.println("You don't have any clubs yet. Add one first."); + new AddClubMenu().present(); + this.present(); + return; + } + + // list clubs + System.out.println("-- YOUR CLUBS --"); + for (int i = 0; i < clubs.length; i++) { + Club c = clubs[i]; + System.out.printf("%d: #%d %s - %s (%s)%n", + i + 1, c.getId(), c.getNickname(), c.getManufacture(), c.getClubType()); + } + + // user selects one of their clubs Scanner sc = new Scanner(System.in); - System.out.print("Club nickname: "); - String nick = sc.nextLine().trim(); - // Defaulted to Driver for now - // TODO update logic - Club club = new Club(0, "Generic", nick, Club.ClubType.DRIVER); + Club club = null; + while (club == null) { + System.out.print("Select club # (1.." + clubs.length + "): "); + String line = sc.nextLine().trim(); + int idx = Integer.parseInt(line); + if (idx < 1 || idx > clubs.length) { + System.out.println("Out of range. Try again."); + continue; + } + club = clubs[idx - 1]; + } // Get shot distance (defaults to 0 of not stated) System.out.print("Distance (yds, blank=0): "); -- cgit v1.2.3