Question
I need help understanding and writing Pseudocode for this C++ program... The only example I have been given is: Good ExampleFollows Steps One at a
I need help understanding and writing Pseudocode for this C++ program... The only example I have been given is:
Good ExampleFollows Steps One at a Time Through the End of the Algorithm
function doProgrammingHomework():
GET a computer
OPEN the Blackboard module
FOR each of the problems in the module
Complete problem
WHILE the problem does not compile
Debug
ENDWHILE
Submit the assignment
ENDFOR
Shut down the computer
>>**But this does not help me to understand how to write the pseudocode for my dice game:<<
#include
#include
#include
#include
using namespace std;
const int DICE = 4;
//Player Class
class Player
{
private:
string name;
int diceLeft;
int hand[DICE];
public:
//constructor
Player(string theName);
int diceCount[6];
//methods
void roll();
void show();
void count();
};
//Player constructor definition
Player::Player(string theName)
{
name = theName;
diceLeft = DICE;
}
//Player method definitions
void Player::roll()
{
for (int i = 0; i < diceLeft; ++i)
{
hand[i] = 1 + rand()%6;
}
}
void Player::show()
{
for (int i = 0; i < diceLeft; ++i)
{
cout << hand[i] << endl;
}
}
void Player::count()
{
for (int i = 0; i < 6; ++i)
{
diceCount[i] = 0;
}
for (int n = 0; n < diceLeft; ++n)
{
diceCount[hand[n]-1]++;
}
}
//MAIN FUNCTION
int main()
{
srand(time(NULL));
//Players
Player p1("Herald");
Player p2("Baloo");
//Everyone Rolls();
cout << " Rolling... ";
p1.roll();
p2.roll();
//Shows player own dice.
cout << "You rolled ";
p1.show();
cout << endl;
p2.show();
cout << endl;
p2.count();
for (int i = 0; i<6; ++i)
{
cout << p2.diceCount[i] << endl;
}
system("pause");
return 0;
}
Edit & Run
>>** This is what I have written so far and I don't even know if it is right:<<
#Get Library
Declare and wrap all Standard Template Library;
Name the integer Dice and = it to the number 4
Name the class to be accessed by the named specifiers
Open a statement
Allow access specifier private:
request the user to input words;
Allow whole numbers and call upon it by using the name diceLeft;
Initialize hand [Initialize the integer DICE];
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started