Dominoes

Hey y'all just need some help with a coding project for school, do not have a lot of help from the professor! So any help is appreciated!! Just need to know if I'm going in the right direction. I'll post what he wants as well.

A domino is a small tile that represents the roll of two dice. The tile, commonly
called a bone, is rectangular with a line down the center. Each end of the tile contains
a number. In the most popular domino set, the double-six, the numbers vary from 0
(or blank) to 6. This produces 28 unique tiles. Dominoes are referred to by the
number of dots (or pips) on each end, with the lower number usually listed first. Thus,
a tile with a 2 on one end and a 5 on the other is referred to as a "2-5". The domino
represented as [2 | 5] is shown to the right.
A tile with the same number on both ends is called a "double", so a "6-6" is
referred to as "double-six". Tiles which have ends with the same number of dots are
members of the same "suit". In a double-six set, there are seven suits (blank, 1, 2, 3, 4, 5, 6),
each with seven members (0-5, 1-5, 2-5, 3-5, 4-5, 5-5, & 5-6) make up the "fives" suit, for
instance. Except for the doubles, each tile belongs to two suits. Write an OO C++ game that plays the
game of dominoes. Here the game will be played by the user and the computer.
When the play begins the dominoes must be randomly shuffled, the collection of shuffled tiles is
called the boneyard. When play begins, the player and computer select 6 dominoes from the set of
dominoes provided from the boneyard, and the holder of the "heaviest" domino goes first as the start of
the "train". Typically, this is the double-six. If no one holds the double-six, then the double-five is played,
and so on. At each turn the player tries to add to the train by placing one of his dominoes with a
matching value at the head (left hand side) or the tail (right hand side) of the train. Note that it may be
necessary to "flip" a domino so that it may be added to the train. For example, if the train is
3
[4 | 5][5 | 7][7 | 3]
then the player may either:
• place a domino that has a 4 on one half (such as [4 | 6] or [0 | 4]) at the head of the train,
creating for example
[6 | 4] [4 | 5] [5 | 7] [7 | 3] (Note that [4 | 6] was "flipped")
OR
[0 | 4] [4 | 5] [5 | 7] [7 | 3]
• place a domino with 3 on one half (such as [3 | 0] or [2 | 3]) at the tail of the train, creating
for example
[4 | 5] [5 | 7] [7 | 3] [3 | 0]
OR
[4 | 5] [5 | 7] [7 | 3] [3 | 2] (Note that [2 | 3] was "flipped")
When it is the computer's turn to play, the program will search its dominoes and play the first domino it
finds that can be added to either the head or the tail of the train. In accordance with the rules described
above. If the player (user or computer) cannot add one of his dominoes to the train, he chooses a
domino from the remaining dominoes in the bone yard and adds it to his dominoes. If the boneyard is
empty, the player simply passes his turn. The next player then takes his turn. A game ends either when
a player (user or computer) plays all his tiles, or when a game is blocked. A game is blocked when no
player is able to add another tile to the layout. A player wins if they are the first to play all their tiles.
Implementation:
• When it is the user's turn to play, you will present the user with a menu.
• You must enforce all game rules and perform all necessary error checking, responding with
appropriate error messages and (if possible) continuing the game.
• If they select a tile not in their hand or cannot be played, they should be re-prompted for
another tile.
• Print user's dominoes -- this choice prints all of the user's dominoes in the format shown in the
example above. Each domino is represented as 2 integers.
• Add a domino to the head of the train -- the user specifies the domino by entering the domino's
2 values (on the same line, separated by a space). The values may be entered in either order. If
the specified domino does not belong to the user, an error is produced and the user must
choose from the menu again. If the domino does belong to the user, it is added to the head of
the train (being automatically flipped if necessary) and removed from the user's set of
dominoes. This choice ends the user's turn.
4
• Add a domino to the tail of the train -- same as adding a domino to the head of the train, but the
domino is added to the tail. This choice ends the user's turn.
• Draw a domino from the bone yard -- the first domino in the boneyard is removed from the
boneyard and added to the user's set of dominoes. If the boneyard is empty, an appropriate
message will be displayed and the user will choose another option from the menu. This choice
will end the user's turn.
• Pass this turn -- It's now the system's turn to play. It is an error for the user to pass his turn if the
boneyard is not empty. This choice ends the user's turn.
• Whenever a domino is added to the train (by either the user or the system), your program will
print the new train.
• When a player (user or system) chooses a domino to add to the train, your program will
automatically "flip" the domino if necessary. See the example in the description above.
Some classes that will be needed are specified below and additional classes can be used. It is up to the
student to figure out what the responsibilities (methods) of each class will be. Those classes are:
• Domino (object) - to represent the entire game. Creating a Domino object should start the game.
• Player (object) - to represent a single player.
Also, no object should directly examine or alter the variables of any other object; all access
should be done by talking to (calling methods of) the other object. The student should figure out
what the various classes and objects should be and what their instance variables and their methods
should be. There is no single "correct" design; any reasonable design will do. The better the design,
the easier the programming will be. Use the objects defined to play a game of Dominoes. The
computer player must play legally, but does not need to play well. Try to make the computer
player "smart," so the human player does not always win. Place all classes into one file. Output
should look similar to below.

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  #include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

class Domino
{

	Domino(int, int);
	int Player(int);
	int AddDom2Head(int);
	int AddDom2Tail(int);
	int Boneyard(int);
	int pass(int Boneyard);
	char printDom;
	int CompChoice();

};





int main()
{

	int playerchoice; //Hold the player choice
	int compchoice;





	do
	{

		cout << "Domino Menu: " << endl;
		cout << "\n1. Print your dominoes" << endl;
		cout << "2. Add a domino to the head of the train" << endl;
		cout << "3. Add a domino to the tail of the train" << endl;
		cout << "4. Pick a domino from the boneyard" << endl;
		cout << "5. Pass your turn (only if the boneyard is empty)" << endl;
		cout << "6. Print this menu" << endl;
		cout << "7.Quit" << endl;


		switch (playerchoice)
		{

		case 1: 
			printDom();

		case 2:
			AddDom2Head();

		case 3:
			AddDom2Tail();

		case 4:
			Boneyard();

		case 5:
			pass();

		case 6:
			PrintMenu();

		Default:
			return 0;

		}




	} 
	while (playerchoice != 7);



	cin.get();
	return 0;

}

int Player(int playerchoice)
{


	cout << "Please enter your choice: ";
	cin >> playerchoice;


	return playerchoice;

}

int CompChoice()
{

	int Comp;

	do
	{
		for (int i = 0; i < 6; i++)
		{
			Comp = rand() % 16 - 1;
		}


	} while (Comp != 6);

		return Comp;

}


int Domino(int, int)
{

	const int MAX = 28;
	int array[MAX] = { };



}

char printDom()
{




}

int AddDom2Head()
{





}

int AddDom2Tail()
{





}


int Boneyard()
{

	int Bone;

	Bone = rand() % 16 - 1;

	return Bone;

}

int pass()
{





}

int PrintMenu()
{





}


This is what I have so far...not sure if I'm even relatively doing this right.
Last edited on
Topic archived. No new replies allowed.