lab5_4 progress
This commit is contained in:
44
lab5_4/Lab5_8_CalebFontenot/Form1.cs
Executable file
44
lab5_4/Lab5_8_CalebFontenot/Form1.cs
Executable file
@@ -0,0 +1,44 @@
|
||||
namespace Lab5_7_CalebFontenot
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
int timesExecuted;
|
||||
private void tossButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Variable to indicate which side is up
|
||||
int sideUp;
|
||||
|
||||
// Create a Random object.
|
||||
Random rand = new Random();
|
||||
|
||||
// Get a random integer in the range of 0 through 1.
|
||||
// 0 means tails up, 1 means heads up.
|
||||
sideUp = rand.Next(2);
|
||||
|
||||
// Display the side that is up.
|
||||
if (sideUp == 0)
|
||||
{
|
||||
// Display tales up.
|
||||
tailsPictureBox.Visible = true;
|
||||
headsPictureBox.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Display heads up.
|
||||
headsPictureBox.Visible = true;
|
||||
tailsPictureBox.Visible = false;
|
||||
}
|
||||
timesExecuted++;
|
||||
label1.Text = "Times run: " + timesExecuted;
|
||||
}
|
||||
|
||||
private void exitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user