Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace SimpleGame
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int userNumber;
- char decision;
- NewGame:
- Console.Clear();
- Random rand = new Random(DateTime.Now.Millisecond);
- int winNumber = Convert.ToInt32(rand.Next(1, 11)); //1-10
- int counter = 1;
- // Console.WriteLine($"Win number: {winNumber} ");
- Start:
- Console.Write("Put a number from range 1-10: ");
- userNumber = int.Parse(Console.ReadLine());
- if (userNumber == winNumber)
- {
- Console.WriteLine("You won!");
- }
- else
- {
- if (counter < 3)
- {
- Console.WriteLine("Try again!");
- //Console.ReadKey();
- counter = counter + 1; //counter++;
- goto Start;
- }
- else
- Console.WriteLine($"You loose! Winning number was: {winNumber}");
- }
- Console.ReadKey();
- 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\tThank You!");
- //Console.ReadKey();
- Thread.Sleep(1000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement