Compare commits
4 Commits
eee5a380ca
...
54b812c0d0
| Author | SHA1 | Date | |
|---|---|---|---|
| 54b812c0d0 | |||
| 0546bb2aa6 | |||
| e2b9e5fd0b | |||
| e742d92a47 |
49
Form1.cs
49
Form1.cs
@ -3,15 +3,62 @@ namespace GuessTheCard
|
|||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
private int score = 0;
|
private int score = 0;
|
||||||
|
private int previousDice;
|
||||||
|
private Random random = new Random();
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Random random = new Random();
|
|
||||||
int randomDice = random.Next(1, 7);
|
int randomDice = random.Next(1, 7);
|
||||||
|
previousDice = randomDice;
|
||||||
labelCard.Text = "Result : " + randomDice;
|
labelCard.Text = "Result : " + randomDice;
|
||||||
labelScore.Text = "Score: " + score;
|
labelScore.Text = "Score: " + score;
|
||||||
|
|
||||||
|
buttonHigh.Click += buttonHigh_Click;
|
||||||
|
buttonLow.Click += buttonLow_Click;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonHigh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PlayRound(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonLow_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PlayRound(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayRound(int guess)
|
||||||
|
{
|
||||||
|
int newDice = random.Next(1, 7);
|
||||||
|
bool isCorrect = false;
|
||||||
|
|
||||||
|
if (newDice > previousDice)
|
||||||
|
{
|
||||||
|
isCorrect = (guess == 1);
|
||||||
|
}
|
||||||
|
else if (newDice < previousDice)
|
||||||
|
{
|
||||||
|
isCorrect = (guess == 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isCorrect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCorrect)
|
||||||
|
{
|
||||||
|
score += 5000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
score = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousDice = newDice;
|
||||||
|
labelCard.Text = "Result : " + newDice;
|
||||||
|
labelScore.Text = "Score: " + score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user