44 lines
1.2 KiB
C#
Executable File
44 lines
1.2 KiB
C#
Executable File
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();
|
|
}
|
|
}
|
|
} |