-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
106 lines (102 loc) · 3.91 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
namespace Task
{
class Program
{
static void Main(string[] args)
{
//Variables
int levelPick= 0;
int trial= 6;
int tries= 4;
int tryy= 3;
Random rnd= new Random();
int easy= rnd.Next(1, 10);
int medium= rnd.Next(1, 20);
int hard= rnd.Next(1, 50);
int guess= 0;
//Intro
Console.WriteLine("*===== Welcome to my number guessing game =====*");
Console.WriteLine("\nThere are 3 levels: 1-Easy, 2-Medium & 3-Hard\n ");
Console.Write("Pick level Number: ");
levelPick= int.Parse(Console.ReadLine());
//LEVEL CONDITIONING
if (levelPick == 1)
{
//////////////////////LEVEL EASY/////////////////////////////
for (int i = 0; i < trial; i++)
{
//NO OF GUESSES LEFT
int guessesLeft= 5 - i;
Console.Write("Enter guess No from 1- 10: ");
//GETTING CORRECT GUESS
guess= int.Parse(Console.ReadLine());
if (guess != easy)
{
Console.WriteLine("That was wrong!");
Console.WriteLine("You have "+ guessesLeft + " guess");
if (guessesLeft == 0)
{
Console.WriteLine("Game over!");
}
}
else
{
Console.WriteLine("You got it right!");
break;
}
}
//NEXT LEVEL
}else if (levelPick == 2)
{
///////////////////////////////LEVEL MEDIUM////////////////////////
for (int i = 0; i < tries; i++)
{
int guessesLeft= 3 - i;
Console.Write("Enter guess No from 1- 20: ");
guess= int.Parse(Console.ReadLine());
if (guess != medium)
{
Console.WriteLine("That was wrong!");
Console.WriteLine("You have "+ guessesLeft + " guess");
if (guessesLeft == 0)
{
Console.WriteLine("Game over!");
}
}
else
{
Console.WriteLine("You got it right!");
break;
}
}
}else if (levelPick == 3)
{
///////////////////////////////LEVEL HARD//////////////////////////////
for (int i = 0; i < tryy; i++)
{
int guessesLeft= 2 - i;
Console.Write("Enter guess No from 1- 50: ");
guess= int.Parse(Console.ReadLine());
if (guess != hard)
{
Console.WriteLine("That was wrong!");
Console.WriteLine("You have "+ guessesLeft + " guess");
if (guessesLeft == 0)
{
Console.WriteLine("Game over!");
}
}
else
{
Console.WriteLine("You got it right!");
break;
}
}
}else
{
Console.WriteLine("\nThere are 3 levels: 1-Easy, 2-Medium & 3-Hard\n ");
}
}
}
}