Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Game
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int userNumber;
- char decision;
- Random rand = new Random(DateTime.Now.Millisecond);
- newGame:
- Console.Clear();
- int winNumber = Convert.ToInt32(rand.Next(1, 11));//randomized number from rande 1-10
- int chances = 3;
- Console.WriteLine($"Win number: {winNumber}");
- userNum:
- Console.Write("Put a number from range 1-10: ");
- userNumber = int.Parse(Console.ReadLine());
- if (userNumber == winNumber)
- {
- Console.Clear();
- Console.WriteLine("\n\n\n\n\n\n\n\t\t\t\t\t\t\tYou won!");
- }
- else
- {
- chances--; // chances = chances - 1;
- if (chances != 0)
- {
- Console.WriteLine("Try again!");
- goto userNum;
- }
- else
- {
- Console.Clear();
- Console.WriteLine("\n\n\n\n\n\n\n\t\t\t\t\t\t\tGame over!");
- }
- }
- Console.Write("Do you want to play again? y - yes: ");
- decision = char.Parse(Console.ReadLine());
- if (decision == 'y')
- goto newGame;
- else
- {
- Console.Clear();
- Console.WriteLine("\n\n\n\n\n\n\n\t\t\t\t\t\t\tThank you!");
- System.Threading.Thread.Sleep(1000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement