hello guys,

im having trouble on how to approach this assignment i have for my c++ class, please i would appreciate all kinds of help and advices. thank you in advance.

The game is a one to three players dice game. At the start of the game there are nine tiles numbered 1 through 9. On each turn a player rolls two six-sided dice and “covers” one tile matching one of the dice or the sum of the dice. For example, if the player rolls 3 and 4 she may cover tile 3, 4, or 7. The player keeps rolling the dice until she can’t cover any more tiles. At this point the turn is passed to the next player. If the game is played by a single player, the play goes to the next round.
Scoring: After each turn the player scores one point for each tile covered.
The game ends after ten rounds or when the player covers all tiles. If there are two or three players, the player with the highest score wins. To win a single player game, all tile must be covered (nine points) after at most ten rounds.

Write a menu driven program that plays the Game of Tiles. The menu should be of the following form:

**********************************
Game of Tiles
Main Menu: Please type your selection!
Single Player [single]
Two Players [two]
Three Players [three]
Quit [quit]
**********************************


The menu should be displayed after each game. Only when the user enters “quit” should the program terminate. You must check for input errors.
Once the user has chosen the number of players, each player should be prompted to enter their name. The player to start must be chosen at random.

Example of the user interface (user input is in bold):
You have chosen to play with two players.
Player 1, please enter your name: Susan
Player 2, please enter your name: Andy
Welcome Susan and Andy!! The player who will start is chosen at random.
Round 1: [ 1] [ 2] [ 3] [ 4] [ 5] [ 6] [ 7] [ 8] [ 9]
Andy, please enter ‘r’ or ’R’ to roll the dice: r
First Die: 1 Second Die: 2 Sum: 3
Tiles: [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ]
Andy, please enter the number of the tile that you would like to cover: 3
Round 1: [ 1 ] [ 2 ] [ X ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ]
Andy, please enter ‘r’ or ‘R’ to roll the dice: r
First Die: 3 Second Die: 3 Sum: 6
Tiles: [ 1 ] [ 2 ] [ X ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ]
Andy, please enter the number of the tile that you would like to cover: 6
Round 1: [ 1 ] [ 2 ] [ X ] [ 4 ] [ 5 ] [ X ] [ 7 ] [ 8 ] [ 9 ]
Andy, please enter ‘r’ or ‘R’ to roll the dice: r
First Die: 3 Second Die: 3 Sum: 6
Tiles: [ 1 ] [ 2 ] [ X ] [ 4 ] [ 5 ] [ X ] [ 7 ] [ 8 ] [ 9 ]
Andy, you have lost your turn.
Your score for round 1 is 2. Your total score is 2.
Round 1: [ 1 ] [ 2 ] [ X ] [ 4 ] [ 5 ] [ X ] [ 7 ] [ 8 ] [ 9 ] Susan, please enter ‘r’ or ’R’ to roll the dice:
...

Your program must perform the necessary logic to end a turn and to end the game. You must check for valid user input. For example, if the player enters a number of a tile that is already covered the program should prompt the user to enter a valid tile number.

To write a game like this one could consider use of loops, arrays, menus, switch statements, generation of random numbers and classes/structs. These are basic tools to creating a program, but depending where you are in your educational process you may or may not be familiar with some or all of them. Since your teacher feels you should be able to create this program, the assumption is most of the topics aren't part of a foreign language at this time. Start with paper and pencil. Here's very preliminary pseudocode that could be used to start the process.

A player has a name, a score card, and a score.
The score card is an array of 9 char (which may be X or digits 1-9)

A dice has 6 possible values (1-6)

A game has one or more players.
A game has 2 dice
To win a game a player must have 9 Xs within 10 rounds or the highest score after 10 rounds
Each round allows one turn per player
Each turn continues as long as that player covers a a square on the card
To cover a square on the card the dice are rolled and the player can cover either the value of a given dice or the sum of both dice.

Note how it is basically a restatement of the instructions in a way that seems a little like coding style. You then expand each segment into more detail and with more coding syntax as it's clear how you want to proceed. Nobody should write the entire program for you, so sharpen you pencil and give it a go.

If you can't get you head around a given topic then ask a specific question and post relevant code (with any error messages) or psuedocode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.