Compare commits
No commits in common. "54b812c0d007bf54bc8eb4881ce88a3c3bd8b299" and "eee5a380ca1d6d138b101794f066734d56ebd220" have entirely different histories.
54b812c0d0
...
eee5a380ca
49
Form1.cs
49
Form1.cs
@ -3,62 +3,15 @@ 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