Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I mostly need help with the BoardSquare and Board classes, as I feel like my Card and Deck classes are pretty solid. Deck: import java.util.ArrayList;

image text in transcribed

image text in transcribed

image text in transcribed

I mostly need help with the BoardSquare and Board classes, as I feel like my Card and Deck classes are pretty solid.

Deck:

 import java.util.ArrayList; import java.util.Random; public class Deck{ public final static int CARDS_IN_DECK = 81; /**  * The collection of Cards  */  public ArrayList deck;; /**  * Current number of Cards in Deck  */  private int ct; /**  * Constructs a regular 81-card deck. Initially, the cards  * are in a sorted order. The shuffle() method can be called to  * randomize the order.  */  public Deck() { freshDeck(); } public void freshDeck() { deck = new ArrayList(CARDS_IN_DECK); for (int color = Card.RED; color GREEN; color++) { for (int fill = Card.FILLED; fill EMPTY; fill++) { for (int rank = Card.SQUIGGLE; rank DIAMOND; rank++) { for (int number = Card.ONE; number THREE; number++) { deck.add(new Card(color, fill, rank, number)); ct = ct + 1; } } } } } /**  * Remove and return the top Card on the Deck  *  * @return A reference to a Card that was top on the Deck  */  public Card getTopCard() { Card c = deck.remove(cardsRemaining() - 1); // remove it (returns removed object) return c; } /**  * Return current number of Cards in Deck  *  * @return number of Cards in Deck  */   public int cardsRemaining() { return deck.size(); } /**  * Randomize the order of Cards in Deck  */   public void shuffle() { int randNum; Card temp; Random r = new Random(); for (int i = 0; i  

}

}

Card:

public class Card { public final static int RED = 0, PURPLE = 1, GREEN = 2; public final static int FILLED = 0, HATCHED = 1, EMPTY = 2; public final static int SQUIGGLE = 0, OVAL = 1, DIAMOND = 2; public final static int ONE = 0, TWO = 1, THREE = 2; private int color; private int fill; private int rank; private int number; public Card(int color, int fill, int rank, int number) { this.color = color; this.fill = fill; this.rank = rank; this.number = number; } public int getColor() { return this.color; } public int getFill() { return this.fill; } public int getRank() { return this.rank; } public int getNumber() { return this.number; } public String ColorToString() { switch (color) { case 0: return "Red"; case 1: return "Purple"; case 2: return "Green"; default: return "?color"; } } public String FillToString() { switch (fill) { case 0: return "Filled"; case 1: return "Hatched"; case 2: return "Empty"; default: return "?fill"; } } public String RankToString() { switch (rank) { case 0: return "Squiggle"; case 1: return "Oval"; case 2: return "Diamond"; default: return "?rank"; } } public String NumberToString() { switch (number) { case 0: return "1"; case 1: return "2"; case 2: return "3"; default: return "?num"; } } public String toString() { if (number > 0) return (NumberToString() + " " + ColorToString() + " " + FillToString() + " " + RankToString() + "s"); else return (NumberToString() + " " + ColorToString() + " " + FillToString() + " " + RankToString()); } public static boolean isSet(Card c1, Card c2, Card c3) { if ((c1.color == c2.color && c2.color == c3.color) && (c1.fill == c2.fill && c2.fill == c3.fill) && (c1.rank == c2.rank && c2.rank == c3.rank) && (c1.number == c2.number && c2.number == c3.number)) return true; else if ((c1.color != c2.color && c2.color != c3.color) && (c1.fill != c2.fill && c2.fill != c3.fill) && (c1.rank != c2.rank && c2.rank != c3.rank) && (c1.number != c2.number && c2.number != c3.number)) return true; else return false; } } 
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, green), a number (one, two or three) and a fill (solid, striped, outlined) Shape Color ova squiggles, purple or diamonds or greern Number Shading solid, striped or outined one, two 2 or three A "set" consists of 3 cards in which each of the cards' features are the same on each card or different on each card. Set examples and more information about the game can be found at setgame.com The game begins by placing 12 cards face up (a 4x3 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. Implementation Phase I We will be implementing this game in three phases. Each phase is dependent up on the prior 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 30th, you will implement the 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, green), a number (one, two or three) and a fill (solid, striped, outlined) Shape Color ova squiggles, purple or diamonds or greern Number Shading solid, striped or outined one, two 2 or three A "set" consists of 3 cards in which each of the cards' features are the same on each card or different on each card. Set examples and more information about the game can be found at setgame.com The game begins by placing 12 cards face up (a 4x3 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. Implementation Phase I We will be implementing this game in three phases. Each phase is dependent up on the prior 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 30th, you will implement the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions