Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Random; public class Deck { /** * Number of cards in standard deck {@value #CARDS_IN_DECK} **/ public final static int CARDS_IN_DECK = 52; /**
import java.util.Random; public class Deck { /** * Number of cards in standard deck {@value #CARDS_IN_DECK} **/ public final static int CARDS_IN_DECK = 52; /** The collection of Cards */ private Card [] deck; /** Current number of Cards in Deck */ private int ct; /** * Constructs a regular 52-card deck. Initially, the cards * are in a sorted order. The shuffle() method can be called to * randomize the order. */ public Deck() { freshDeck(); } /** * Create a new collection of 52 cards, in sorted order */ public void freshDeck() { deck = new Card[CARDS_IN_DECK]; for (int r = Card.ACE; rthis is another "deck" that might be useful. but do not copy the whole thing.
------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Random; import java.util.ArrayList; public class Deck1 { /** * Number of cards in standard deck {@value #CARDS_IN_DECK} **/ final int CARDS_IN_DECK = 52; /** The collection of Cards */ private ArrayListbb.uvm.edu The Game of SET- Part I Due Monday, October 30h. Complete javadocs documentation is required. 15points/class-60 points total Board class-The representation of the face up cards. Initially the board is 3 rows of 4 cards. Each row is an ArrayList, BoardSquares. The entire Board is an ArrayList of rows. Therefore the Board is an ArrayList of ArrayLists of BoardSquares. SET is a card game that can be played solo or with several people. There are 81 cards in the deck. Each card has 4 features:a shape (oval, squiggle or diamond), a color (red, purple, greenl, a number (onc, two or three) and a fill (solid, striped, outlined). rrayListdeck; /** * Constructs a regular 52-card deck. Initially, the cards * are in a sorted order. The shuffle() method can be called to * randomize the order. */ public Deck1() { freshDeck(); } /** * Create a new collection of 52 cards, in sorted order */ public void freshDeck() { deck = new ArrayList (CARDS_IN_DECK); for (int r = Card.ACE; r high.getRank()) { high = cards[i]; } } return high; } } > board The only constructor for the Board class takes a Deck object. The constructor populates the ArrayList of ArrayLists with the top 12 cards of the supplied deck. Other methods to implement Shape Color replaceCard(Card,row,col)-the BoardSquare at row, col will now hold the newly supp ed Card getBoardSquaerow,col)-return the BoardSquare at the specified row,col add3(Deck)-add 3 cards from the Deck by adding 1 card to each row getCard row,col-return a reference to the Card at specified row and col numRows0 how many rows numCols()-how many in each row (initially 4, but more if 'add3' invoked) toStringl) -return a String representation of the Board squiggles, purple, or diamonds or green Number ng solid, 900 striped Here's a tester for your Board class: 2 two, Deck d = new Deck(); d.shuffle Board b = new Board(d); System.out.printin (b) System.out.printin (b.getCard (O,0) System.out-printin (b) or outlined Set A "set" consists of 3 cards in which each of the cards' features are the same on each card or different on each card. examples and more information about the game can be found at setgame.com. if (Card.inSet (b.getCard (0,0), b.getcard(o,l),b.getcard0,2) The game begins by placing 12 cards face up (a 43 grid of cards). The player identifies sets of cards. When a set is identified, the three cards are removed from the board and replaced with three new cards from the deck. If, at any time the player decides there are no sets in the 12 cards, they may flip 3 more cards. if there are still no sets, they may flip 3 more cards. The maximum number of cards, face up on the table, at any time is 18. The play continues until the deck is depleted. Syatem.out.println("set") i else System.out.println("not a set" Implementation Phase l The output of my run (remember, it is We wil be implementing this game in three phases. Each phase is dependent up on the priar phase, so it is imperative that you do not fall behind. We will be implementing a solitaire version. For the first phase, due Monday, October 30h, you will implement the following classes: Card class-represent one card. Each card has 4 features. Use enumerated types to represent the possible values for each features (for example: OUTLINE, SOLID, HATCHED). The class has only one constructor that accepts a Color, Fill Rank and Number. Once a Card s created; it is never changed. Implement at tostring method. Include a dass (static) method that takes 3 Cards and determines if they form a set. not a set Deck class-an ArrayList of Card Objects. The dass has only one constructor, a default (no-arg) constructor that creates the 81 card deck. Include methods for shuffle,tostring, 18Enpty and getTopCard. The getTopCard method should return a reference to the Card being removed from the Deck (not a copy!) Boardsquare class- Each square on the "board" will contain a Card, as well its row, col position in the Board and some indication of whether or not the square is selected. The class has a single constructor that takes in a card, an integer row position, an integer column position. The BoardSquare is initiaized to be unselected. Implement getters and setters for all instance variables bb.uvm.edu The Game of SET- Part I Due Monday, October 30h. Complete javadocs documentation is required. 15points/class-60 points total Board class-The representation of the face up cards. Initially the board is 3 rows of 4 cards. Each row is an ArrayList, BoardSquares. The entire Board is an ArrayList of rows. Therefore the Board is an ArrayList of ArrayLists of BoardSquares. SET is a card game that can be played solo or with several people. There are 81 cards in the deck. Each card has 4 features:a shape (oval, squiggle or diamond), a color (red, purple, greenl, a number (onc, two or three) and a fill (solid, striped, outlined). rrayList > board The only constructor for the Board class takes a Deck object. The constructor populates the ArrayList of ArrayLists with the top 12 cards of the supplied deck. Other methods to implement Shape Color replaceCard(Card,row,col)-the BoardSquare at row, col will now hold the newly supp ed Card getBoardSquaerow,col)-return the BoardSquare at the specified row,col add3(Deck)-add 3 cards from the Deck by adding 1 card to each row getCard row,col-return a reference to the Card at specified row and col numRows0 how many rows numCols()-how many in each row (initially 4, but more if 'add3' invoked) toStringl) -return a String representation of the Board squiggles, purple, or diamonds or green Number ng solid, 900 striped Here's a tester for your Board class: 2 two, Deck d = new Deck(); d.shuffle Board b = new Board(d); System.out.printin (b) System.out.printin (b.getCard (O,0) System.out-printin (b) or outlined Set A "set" consists of 3 cards in which each of the cards' features are the same on each card or different on each card. examples and more information about the game can be found at setgame.com. if (Card.inSet (b.getCard (0,0), b.getcard(o,l),b.getcard0,2) The game begins by placing 12 cards face up (a 43 grid of cards). The player identifies sets of cards. When a set is identified, the three cards are removed from the board and replaced with three new cards from the deck. If, at any time the player decides there are no sets in the 12 cards, they may flip 3 more cards. if there are still no sets, they may flip 3 more cards. The maximum number of cards, face up on the table, at any time is 18. The play continues until the deck is depleted. Syatem.out.println("set") i else System.out.println("not a set" Implementation Phase l The output of my run (remember, it is We wil be implementing this game in three phases. Each phase is dependent up on the priar phase, so it is imperative that you do not fall behind. We will be implementing a solitaire version. For the first phase, due Monday, October 30h, you will implement the following classes: Card class-represent one card. Each card has 4 features. Use enumerated types to represent the possible values for each features (for example: OUTLINE, SOLID, HATCHED). The class has only one constructor that accepts a Color, Fill Rank and Number. Once a Card s created; it is never changed. Implement at tostring method. Include a dass (static) method that takes 3 Cards and determines if they form a set. not a set Deck class-an ArrayList of Card Objects. The dass has only one constructor, a default (no-arg) constructor that creates the 81 card deck. Include methods for shuffle,tostring, 18Enpty and getTopCard. The getTopCard method should return a reference to the Card being removed from the Deck (not a copy!) Boardsquare class- Each square on the "board" will contain a Card, as well its row, col position in the Board and some indication of whether or not the square is selected. The class has a single constructor that takes in a card, an integer row position, an integer column position. The BoardSquare is initiaized to be unselected. Implement getters and setters for all instance variables
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started