-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
57 lines (50 loc) · 1.25 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
Console.WriteLine("-------------------------------");
Console.WriteLine("Russian Roulette");
Console.WriteLine("-------------------------------");
Random random = new Random();
int ChamberChosen = 0;
while (ChamberChosen < 1 || ChamberChosen > 6)
{
Console.WriteLine("Pick a Chamber. (1-6)");
if (int.TryParse(Console.ReadLine(), out int result) && result >= 1 && result <= 6)
{
ChamberChosen = result;
}
else
{
Console.WriteLine("Invalid input. Please enter a number between 1 and 6.");
}
}
int BulletChamber = random.Next(1, 7);
bool playAgain = true;
bool Looped = false;
while (playAgain)
{
if (ChamberChosen == BulletChamber)
{
Console.WriteLine("Bang!");
Console.Beep();
playAgain = false;
}
else
{
Console.WriteLine("Click.\nShoot Again? (y,n)");
string response = Console.ReadLine().ToLower();
if (response == "n")
{
Console.WriteLine("Goodbye!");
Console.ReadKey();
playAgain = false;
}
else
{
BulletChamber++;
if (BulletChamber > 6)
{
BulletChamber = 1;
}
Looped = true;
}
}
}
Console.ReadKey();