I am making a game called Set, it is a card game: here is a brief description of the rules:
The game of Set is played with 81 cards, each of which has 4 properties (number, pattern,
color and shape). The number of objects is 1, 2, or 3. The 3 possible patterns are solid,
striped, and open. The 3 possible colors are red, green, and purple. The 3 possible
shapes are diamond, squiggle, and oval. The 81 cards comprise all possible combinations
of patterns, colors and shapes. Some example cards are:
• 1 Striped red oval
• 2 Solid green squiggle
• 3 Open purple diamond
Ok now what I am having trouble with is creating my deck of 81 cards. The way I am trying to do it is by creating a buch of nested for loops (should only be 4) that goes through each array and gets a number, color, shape and pattern. If nested right I should be able to create a deck of cards that has 81 possible combination's of numbers, colors, shapes and patterns.
As you can see I have Card deck = cards.get(i);, well I should also be able to get j, k, and m. But I have no idea where I should put that. And after I get that settled, I should be able to put what ever is at i, k, k, and m, and add that to the deck.
The game of Set is played with 81 cards, each of which has 4 properties (number, pattern,
color and shape). The number of objects is 1, 2, or 3. The 3 possible patterns are solid,
striped, and open. The 3 possible colors are red, green, and purple. The 3 possible
shapes are diamond, squiggle, and oval. The 81 cards comprise all possible combinations
of patterns, colors and shapes. Some example cards are:
• 1 Striped red oval
• 2 Solid green squiggle
• 3 Open purple diamond
Ok now what I am having trouble with is creating my deck of 81 cards. The way I am trying to do it is by creating a buch of nested for loops (should only be 4) that goes through each array and gets a number, color, shape and pattern. If nested right I should be able to create a deck of cards that has 81 possible combination's of numbers, colors, shapes and patterns.
Code:
import java.util.Scanner; import java.util.*; /** * Write a description of class GameOfSet here. * @author (Michael Brown) * @version (a version number or a date) */ public class GameOfSet { ArrayList<Card> cards; //An array list of card objects /** * Constructor for objects of class GameOfSet * @param String to determine Shape and String to determine color * @param number can be 1-3 * @param color can be red, green, purple * @param pattern can be solid, stripped, open * @param shape can be diamond, squiggle, oval * */ public GameOfSet() { cards = new ArrayList<Card>(); Card cards = new Card ("1", "solid", "purple", "oval" ); //One card from the Cards ArraysList that has 4 perameters } /** * Deck of 81 cards * nested for loop will create 81 possible * combinations of number, color, pattern, and shape * each card will have one number, pattern, color and shape */ public void getDeckOfCards() { ArrayList<String> number = new ArrayList<String>(3); //ArrayList of numbers number.add("1"); number.add("2"); number.add("3"); ArrayList<String> color = new ArrayList<String>(3); //ArrayList of colors color.add("red"); color.add("green"); color.add("purple "); ArrayList<String> pattern = new ArrayList<String>(3); //ArrayList of patterns pattern.add("solid"); pattern.add("striped"); pattern.add("open"); ArrayList<String> shape = new ArrayList<String>(3); //ArrayList of Shapes shape.add("diamond"); shape.add("squiggle"); shape.add("oval"); for(int i = 0; i < number.size(); i++) { for(int j = 0; j < color.size(); j++) { Card deck = cards.get(i); for(int k = 0; k < pattern.size(); k++) { for(int m = 0; m < shape.size(); m++) { } } } } } }
As you can see I have Card deck = cards.get(i);, well I should also be able to get j, k, and m. But I have no idea where I should put that. And after I get that settled, I should be able to put what ever is at i, k, k, and m, and add that to the deck.
Comment