Question
I need help with updating the rich text box with the information and I'm not sure how to go about doing that. As for the
I need help with updating the rich text box with the information and I'm not sure how to go about doing that. As for the labels in the game info box, I have the code to update them but I need to add that in if statements to update accordingly. When you enter your guess in the textbox and click the roll button its supposed to update whether you got it right or wrong and print out the information in the text box for the percentage and guess for each face value of the dice.
Create a Windows Forms based program that allows the user to guess what the value of a rolled 6-sided dice will be. The program will display to the user how many times they have played and how many times they have guessed right or wrong. The program will also keep track of the frequency and percentage that each number was rolled, and the number of times the user guessed that number. The program will also have a reset button that returns the game to its initial state.
When the roll button is pressed the dice image should randomly change a couple of times to simulate it rolling. This can be done with a for loop and calling the Thread.Sleep() method in the System.Threading namespace. You will also need to refresh the image. Make sure to check for valid input from the user. Only values of 1 through 6 should be allowed to be entered by the user. Only 1 digit should be allowed to be entered in the textbox, by setting the MaxLength property of the textbox. If an invalid value is entered, a label containing an error message should be displayed next to the users guess textbox.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Threading;
namespace Assignment_2 { public partial class Die_Guess_Game : Form { public Die_Guess_Game() { InitializeComponent(); }
private void Roll_Click(object sender, EventArgs e) { //Times_Played_Number.Text = (int.Parse(Times_Played_Number.Text) + 1).ToString(); //Times_Won_Number.Text = (int.Parse(Times_Won_Number.Text) + 1).ToString(); //Times_Lost_Number.Text = (int.Parse(Times_Lost_Number.Text) + 1).ToString();
Dice_PB.SizeMode = PictureBoxSizeMode.StretchImage; Random r = new Random();
for (int i = 1; i
private void Dice_PB_Click(object sender, EventArgs e) {
}
private void Reset_Click(object sender, EventArgs e) { Dice_PB.Image = null; Dice_Throw_Info.Clear(); Times_Played_Number.ResetText(); Times_Won_Number.ResetText(); Times_Lost_Number.ResetText(); Guess_TB.Text = null; } } }
-Game Info Number of Times Played: 3 Number of Times Won: 1 Number of Times Lost 2 Enter your guess (1-6): -Game Info Number of Times Played: 3 Number of Times Won: 1 Number of Times Lost 2 Enter your guess (1-6)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