-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoard.java
More file actions
45 lines (42 loc) · 1.29 KB
/
Board.java
File metadata and controls
45 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.concurrent.ThreadLocalRandom;
import java.util.*;
import java. util. Collection;
import java.util.Random;
import java.util.ArrayList;
/**
* Board: A n x m game board made of of individualab tiles.
*
* For the game of concentraiton",the board is made up of
* pairs of matching strings, one string per tile.
*
* Precondition: the size of the cards array must fit into the rows/columns shape of the board
*/
public abstract class Board
{
//The cards that will be placed in the tiles
private String[] cards = new String[] {"dog", "dog", "cat", "cat", "mouse", "mouse",
"wolf", "wolf", "monkey", "monkey", "bird", "bird"};
private List <String> AL = Arrays.asList(cards);
// The shape of the board
private int rows = 3;
private int columns = 4;
/**
* Create a 2-dim array to represent a game board and return it
*
* @return a game board of tiles with dimension rows x columns
*/
public Tile[][] makeBoard() {
return new Tile[rows][columns];
}
/**
* Return the array of cards
*
* @return a String array of card values
*
*/
public String[] getCards () {
Collections.shuffle(AL);
cards = AL.toArray(new String[AL.size()]);
return cards;
}
}