-
Notifications
You must be signed in to change notification settings - Fork 126
/
Program.cs
62 lines (60 loc) · 1.76 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
int playerPoints = 0;
int rivalPoints = 0;
Console.WriteLine("Dice Game");
Console.WriteLine();
Console.WriteLine("In this game you and a computer Rival will play 10 rounds");
Console.WriteLine("where you will each roll a 6-sided dice, and the player");
Console.WriteLine("with the highest dice value will win the round. The player");
Console.WriteLine("who wins the most rounds wins the game. Good luck!");
Console.WriteLine();
Console.Write("Press any key to start...");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();
for (int i = 0; i < 10; i++)
{
Console.WriteLine($"Round {i + 1}");
int rivalRandomNum = Random.Shared.Next(1, 7);
Console.WriteLine("Rival rolled a " + rivalRandomNum);
Console.Write("Press any key to roll the dice...");
Console.ReadKey(true);
Console.WriteLine();
int playerRandomNum = Random.Shared.Next(1, 7);
Console.WriteLine("You rolled a " + playerRandomNum);
if (playerRandomNum > rivalRandomNum)
{
playerPoints++;
Console.WriteLine("You won this round.");
}
else if (playerRandomNum < rivalRandomNum)
{
rivalPoints++;
Console.WriteLine("The Rival won this round.");
}
else
{
Console.WriteLine("This round is a draw!");
}
Console.WriteLine($"The score is now - You : {playerPoints}. Rival : {rivalPoints}.");
Console.Write("Press any key to continue...");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();
}
Console.WriteLine("Game over.");
Console.WriteLine($"The score is now - You : {playerPoints}. Rival : {rivalPoints}.");
if (playerPoints > rivalPoints)
{
Console.WriteLine("You won!");
}
else if (playerPoints < rivalPoints)
{
Console.WriteLine("You lost!");
}
else
{
Console.WriteLine("This game is a draw.");
}
Console.Write("Press any key to exit...");
Console.ReadKey(true);