diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
| commit | 81ba9eb66f8284d8760012973f84cdbe617ceb94 (patch) | |
| tree | 466432644e9e3fd66ee183ec53a1f10abb1b7faa /c1/Client.java | |
Diffstat (limited to 'c1/Client.java')
| -rw-r--r-- | c1/Client.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/c1/Client.java b/c1/Client.java new file mode 100644 index 0000000..3bde980 --- /dev/null +++ b/c1/Client.java @@ -0,0 +1,36 @@ +import java.util.*; + +public class Client { + public static void main(String[] args) { + Scanner console = new Scanner(System.in); + AbstractStrategyGame game = new ConnectFour("dude", "bro"); + + System.out.println(game.instructions()); + System.out.println(); + + while (!game.isGameOver()) { + System.out.println(game); + System.out.printf("Player %d's turn.\n", game.getNextPlayer()); + try { + game.makeMove(console); + } catch (IllegalArgumentException ex) { + System.out.println("**Illegal move: " + ex.getMessage()); + } + /** + * Note - the above structure is a try/catch, which is something + * we've included to help deal with the IllegalArgumentExceptions + * in your abstract strategy game! + * We want to remind you that try/catch is a forbidden feature in 123, + * so you SHOULD NOT INCLUDE IT in any code you submit (other than this file)! + * Please see the Code Quality Guide for more info on this. + */ + } + System.out.println(game); + int winner = game.getWinner(); + if (winner > 0) { + System.out.printf("Player %d wins!\n", winner); + } else { + System.out.println("It's a tie!"); + } + } +} |
