Question

In: Computer Science

Fly By Night Games Company has decided to hire you to program their new board game...

Fly By Night Games Company has decided to hire you to program their new board game simulator for the game “Chutes & Ladders”. The board has squares which are numbered from 1 to 100 and players have counters which start on the theorectical square 0. The players take turns at spinning a spinner with the numbers 1 to 6 on it, and each moves his or her counter forward the number of squares corresponding to the number on the spinner. The first person to reach square 100 is the winner. The interest is caused by the fact that pairs of squares are connected together by "ladders" (which connect a lower-numbered square to a higher-numbered square) and "chutes" (which run from high to low). If a counter lands on the start of a chute or ladder, the counter is moved to the corresponding square at the end of the chute or ladder. Note that landing on the end square of a ladder or a chute has no effect, only the start square counts. If a player is on square 95 or higher, then a spin which takes them past 100 must be ignored (for example, a player on square 99 must ignore all spins which are not 1) and the player should be told that the spin is ignored. Ladders and Chutes are shown in the tables below (on page 2). In C++, using functions and loops: 1. Design your game so the user plays in the following manner: Allow two players to play the game and ask the users for their names. The player "spins" and is told the result of their spin. If they land on the start of a chute or ladder, they are told about it. The player should be told where they end up. The other player then spins. Once a player has reached 100, the game ends with an appropriate message. Then, offer to play again. 2. Note that once a player has reached 100, the game should immediately end. The other player does not get another turn. 3. When your program starts execution, it needs to display a welcome message that describes the program to user in a short, but clear message. Blank lines appear before and after the welcome message to help user read the screen. In addition, goodbye message should be displayed to wrap up the program before exiting. Again, blank lines appear before and after the goodbye message to help user read the screen.

Solutions

Expert Solution

#include<cstdlib>

#include <iostream>

using namespace std;

int counter1;

int counter2;

int spinner;

int spin;

char name1[20];

char name2[20];

int opinion1;

int opinion2;

void player1()

{

cout<<"Now it is the turn of "<<name1<<" to play"<<endl;

cout<<"enter 1 to spin";

while(spin!=1)

cin>>spin;

spinner=rand()%6+1;

cout<<"The result of spin is "<<spinner<<endl;

if(counter1>=95 && counter1+spinner>100)

cout<<"spin is ignored"<<endl;

else

{

counter1+=spinner;

cout<<"You ended up at the square "<<counter1<<endl;

}

}

void player2()

{

cout<<"Now it is the turn of "<<name2<<" to play"<<endl;

cout<<"enter 1 to spin";

while(spin!=1)

cin>>spin;

spinner=rand()%6+1;

cout<<"The result of spin is "<<spinner<<endl;

if(counter2>=95 && counter2+spinner>100)

cout<<"spin is ignored"<<endl;

else

{

counter2+=spinner;

cout<<"You ended up at the square "<<counter2<<endl;

}

}

void start()

{

cout<<"\n"<<"Welcome to Chutes and Ladders"<<"\n";

cout<<"\nEnter the name of player1";

cin>>name1;

cout<<"Enter the name of player2";

cin>>name2;

}

int main() {

start();

while(1)

{

counter1=0;

counter2=0;

while(counter1!=100 && counter2!=100)

{

spin=0;

player1();

spin=0;

player2();

}

if(counter1==100)

cout<<name1<<" is the winner";

else

cout<<name2<<" is the winner";

cout<<"You are invited to play again"<<endl;

cout<<name1<<" enter 1 to play again";

cin>>opinion1;

cout<<name2<<" enter 1 to play again";

cin>>opinion2;

if(opinion1!=1 || opinion2!=1)

exit(0);

}

cout<<"\nGoodbye"<<endl;

}


Related Solutions

Magic Realm, Inc., has developed a new fantasy board game. The company sold 24,600 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 24,600 games last year at a selling price of $68 per game. Fixed expenses associated with the game total $410,000 per year, and variable expenses are $48 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 35,600 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 35,600 games last year at a selling price of $62 per game. Fixed expenses associated with the game total $623,000 per year, and variable expenses are $42 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 40,000 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 40,000 games last year at a selling price of $69 per game. Fixed expenses associated with the game total $720,000 per year, and variable expenses are $49 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 28,200 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 28,200 games last year at a selling price of $70 per game. Fixed expenses associated with the game total $470,000 per year, and variable expenses are $50 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 45,000 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 45,000 games last year at a selling price of $68 per game. Fixed expenses associated with the game total $810,000 per year, and variable expenses are $48 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 45,000 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 45,000 games last year at a selling price of $68 per game. Fixed expenses associated with the game total $810,000 per year, and variable expenses are $48 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 27,600 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 27,600 games last year at a selling price of $67 per game. Fixed expenses associated with the game total $460,000 per year, and variable expenses are $47 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 15,000 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 15,000 games last year at a selling price of $20 per game. Fixed expenses associated with the game total $182,000 per year, and variable expenses are $6 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 40,000 games last...
Magic Realm, Inc., has developed a new fantasy board game. The company sold 40,000 games last year at a selling price of $65 per game. Fixed expenses associated with the game total $700,000 per year, and variable expenses are $45 per game. Production of the game is entrusted to a printing contractor. Variable expenses consist mostly of payments to this contractor. Required: 1-a. Prepare a contribution format income statement for the game last year. 1-b. Compute the degree of operating...
Drake is a department manager in a company which has recently decided to hire a new...
Drake is a department manager in a company which has recently decided to hire a new analyst. After interviewing all candidates, Drake recommended the company hire Anne, but senior management preferred to hire Beth. Drake argued that Beth is an inferior choice, but agreed to accept her for a trial period of six months. At the end of the trial period, Drake evaluated Beth’s performance as poor. Although this evaluation may have been fair, it is also possible that it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT