Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have finished the program, however at the end of the game i cant link my progr

ID: 3626618 • Letter: I

Question

I have finished the program, however at the end of the game i cant link my program to the "win" function. Can somebody help me?


#include <iostream>

using namespace std;

void Heap_setup(int heapcount[], int numberofheaps);

void Player_turn(int &player);

void read_heaps(const int heapsread[], int numberofheaps);

void heap_drawing(int heapsread[], int numberofheaps);

void turn(int heapsread[], int player, int numberofheaps);

void win(int Player);


int main()
{
int x = 0;
int Players = 1;
cout << "How many heaps do you want to use? ";
cin >> x;
int heaps[x];
for (int i = 0; i < x; i++)
{
heaps[i] = 0;
}

Heap_setup(heaps, x);

Player_turn(Players);

read_heaps(heaps, x);

int sum = 0;
for (int i = 0; i < x; i++)
{
sum += heaps[i];
}

heap_drawing(heaps, x);

while (sum > 0)
{

turn(heaps, Players, x);

int sum = 0;
for (int i = 0; i < x ; i++)
{
sum += heaps[i];
}

read_heaps(heaps, x);

heap_drawing(heaps, x);

Player_turn(Players);

}
win(Players);
system("pause");
return(0);
}

void Heap_setup(int heapcount[], int numberofheaps)
{
int objects = 0;

cout << "How many objects do you want in each heap? ";
cin >> objects;

for(int i = 0; i < numberofheaps; i++)
{
heapcount[i] = objects;
}
}

void Player_turn(int & player)
{
if (player == 1)
{
player == player - 1;
}
else
{
player == player + 1;
}
if (player == 1)
{
cout << "Player 2's turn!";
}
else
{
cout << "Player 1's turn!";
}
}

void read_heaps(const int heapsread[], int numberofheaps)
{
for (int i = 0; i < numberofheaps; i++)
{
cout << "heap " << i << " has " << heapsread[i] << " objects!" << endl;
}
}

void heap_drawing(int heapsread[], int numberofheaps)
{
int objectsinheap = 0;
for (int i = 0; i < numberofheaps; i++)
{
cout << "Heap " << i << ":";
objectsinheap = heapsread[i];
for (int star = 0; star < objectsinheap; star++)
{
cout << "*";
}
cout << endl;
}
}

void turn(int heapsread[], int player, int numberofheaps)
{
int heap_number = 0;
int remove = 0;
if(player == 1)
{
cout << "Player 2, which heap would you like to remove objects from? ";
}
else
{
cout << "Player 1, which heap would you like to remove objects from) ";
}
cin >> heap_number;

while(heap_number >= numberofheaps || heap_number < 0 || heapsread[heap_number]==0)
{
cout << "ERROR! You must enter a valid heap!";
cin >> heap_number;
}
cout << "How many heaps would you like to remove?";
cin >> remove;

while (remove > heapsread[heap_number] || remove <= 0)
{
cout << "ERROR! There aren't that many objects! Use a smaller number please!";
cin >> remove;
}
heapsread[heap_number]= heapsread[heap_number]-remove;
}

void win(int Player)
{
if (Player == 1)
{
cout << "Player 1 wins!";
}
else
{
cout << "Player 2 wins!";
}
}

Explanation / Answer

hi there if u can explain the game so when the player wins or how is the game played