C# roll dice minimize number of dice every round
i need help please anyone. I did an array and a loop that stops when a number is identified. Its not suppose to happen that way.
It rolls 5 dice but when a number is identified, it should lessen the number of dice for the next round. It plays 3 rounds altogether until that number is identified. It should identify 6 then 5 .... only three round is given.
The problem is i want it to display everything in the array before and tell that the number exist.
public dice()
{
int Round = 0;
int Dice = 5;
int Six = 6;
int Five = 5;
int Four = 4;
int NOW = Six;
do
{
for (int i = 0; i < Dice; i++)
{
{
rolldice();
Console.Write("{0} ", die.Face());
}
}
if (die.Face() == NOW)
{
Dice--;
Console.WriteLine("You got SIX");
Now = Five;
}
Console.WriteLine("ENTER to roll {0} dice", Dice);
Round++;
}
开发者_StackOverflow while (Round < 3);
Should display:
4 3 2 4 6 you got SIX
ENTER to roll 4 dice
1 1 5 3 you got FIVE
ENTER to roll 3 dice
You're rolling all the dice, and then just checking the last one - all your tests are outside the loop.
That's just the first step in making this work though - there are various other issues with it. In particular, I would suggest having just one condition, not three... you only want to see whether any of the dice has the current value you're looking for.
I'll leave it at that for the moment, so you can learn by thinking it through for yourself - but when you're happy with what you've got, you can always ask for hints as to how to improve the solution too.
精彩评论