import java.util.ArrayList; import java.util.Scanner; public class Main { static final int START_CARDS = 7; static final int NUMBER_OF_SETS = 13; public static void game(ArrayList players) { Deck deck = new Deck(); deck.add52(); deck.shuffle(); // deal out starting cards for (int i = 0; i < START_CARDS; i++) { for (Player p : players) { p.addCard(deck.deal()); } } // count how many sets have been played int totalSets = 0; while (totalSets < NUMBER_OF_SETS) { // do a move for each player for (Player p : players) { p.move(players, deck); // add up sets played so far totalSets = 0; for (Player player : players) { totalSets += player.getSets(); } if (totalSets == NUMBER_OF_SETS) { break; } } } // find and print the winner of the game System.out.println("The game is over!"); Player winner = players.get(0); for (Player p : players) { System.out.println(p.getName() + " has " + p.getSets() + " sets."); if (p.getSets() > winner.getSets()) { winner = p; } } System.out.println("The winner is " + winner.getName() + "!"); } public static void main(String args[]) { System.out.println("What is your name? "); Scanner in = new Scanner(System.in); String name = in.nextLine(); // start the game with 3 ai players ArrayList players = new ArrayList(); players.add(new Player(name, true)); players.add(new Player("Alice", false)); players.add(new Player("Bob", false)); players.add(new Player("Claire", false)); game(players); } }