Question: I need help with a c++ program. Here are some requirements: Create a Nim game using c++ (Nim resource: https://plus.maths.org/content/play-win-nim) The game should have an

I need help with a c++ program. Here are some requirements:

Create a Nim game using c++ (Nim resource: https://plus.maths.org/content/play-win-nim)

The game should have an intro explaining how the board works. (See sample output #1)

The game should print the gameboard to start and then after every turn. (Please no extra prints.)

The program included Row.h and Board.h which I will provide below

Row.h have a pointer to a Boolean which will use as an array

The Row.h is responsible for finding out which cells will be crossed out.

The Board.h has a play method that loops and plays the game

Board.h: The only publicly available methods are play() and print(). All other methods are private

The main program should be small. At most have the intro and a call to the play method.

The player loses if:

They don't pick a cell. This can happen either if the other player has beat them or if they are silly and don't pick one. They don't pick a row between 1 and 3.

IOW we aren't really editing user input. If they enter something goofy, they lose.

Board.h I need help with a c++ program. Here are some requirements: Create

Row.h

a Nim game using c++ (Nim resource: https://plus.maths.org/content/play-win-nim) The game should have

Output example:

an intro explaining how the board works. (See sample output #1) The

game should print the gameboard to start and then after every turn.

Thank you very much!

#pragma once #include #include "Row.h" class Board { Row r3{ 3 }; Row r5{ 5 }; Row r7{ 7 }; bool take_turn(int player); int nimSum() const; public: void print() const; void play(); #pragma once A class Row { bool* r; int _size; public: Row(int size = 1); Row(); int spots_left() const; void print() const; bool cross_out(int row); C:\Users\PaulaH\source epos\PointerLabNim Debug\PointerLabNim.exe Welcome to Nim Take turns removing dots from one of 3 rows First Player unable to move loses x's are already crossed out. --- Lets Play! --- 1: OOO 2: ooooo : ooooooo --- --- Player 1 take a turn What row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 Cross out column 0 (Y/N) ? y Cross out column 1 (Y/N) ? y Cross out column 2 (Y/N) ? n Result of turn 1: 1 x 0 2: ooooo : ooooooo Nim-Sum 3 --- --- Player 2 take a turn What row do you want to cross out from? Player 1 take a turn What row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 Cross out column 0 (Y/N) ? Y Cross out column 1 (Y/N) ? Y Cross out column 2 (Y/N) ? N Result of turn 1: X X 0 2: OOO : ooooooo Nim-Sum? 0 --- Player 2 take a turn what row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 XXO Cross out column 2 (Y/N) ? #pragma once #include #include "Row.h" class Board { Row r3{ 3 }; Row r5{ 5 }; Row r7{ 7 }; bool take_turn(int player); int nimSum() const; public: void print() const; void play(); #pragma once A class Row { bool* r; int _size; public: Row(int size = 1); Row(); int spots_left() const; void print() const; bool cross_out(int row); C:\Users\PaulaH\source epos\PointerLabNim Debug\PointerLabNim.exe Welcome to Nim Take turns removing dots from one of 3 rows First Player unable to move loses x's are already crossed out. --- Lets Play! --- 1: OOO 2: ooooo : ooooooo --- --- Player 1 take a turn What row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 Cross out column 0 (Y/N) ? y Cross out column 1 (Y/N) ? y Cross out column 2 (Y/N) ? n Result of turn 1: 1 x 0 2: ooooo : ooooooo Nim-Sum 3 --- --- Player 2 take a turn What row do you want to cross out from? Player 1 take a turn What row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 Cross out column 0 (Y/N) ? Y Cross out column 1 (Y/N) ? Y Cross out column 2 (Y/N) ? N Result of turn 1: X X 0 2: OOO : ooooooo Nim-Sum? 0 --- Player 2 take a turn what row do you want to cross out from? 1 Crossing out from row: 1 0 1 2 XXO Cross out column 2 (Y/N)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!