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.Tasks;
- namespace Bingo
- {
- class Program
- {
- static void Main(string[] args)
- {
- start:
- Console.WriteLine("Please put in ten numbers between 1-25. please only use whole numbers." +
- (" " + "Please make sure you only write numbers you have not already entered."));
- int[] usernumbers = new int[10];
- for (int i = 0; i <= 9; ++i)
- {
- int input;
- do
- {
- input = askForInt();
- } while (!checkIfUnique(usernumbers, input));
- usernumbers[i] = input;
- }
- // random nr generator
- Random boxOfRandomNr = new Random();
- int[] randomnumbers = new int[7];
- for (int i = 0; i <= 6; ++i)
- {
- int random;
- do
- {
- random = boxOfRandomNr.Next(1, 26);
- } while (!checkIfUnique(randomnumbers, random));
- randomnumbers[i] = random;
- }
- int score = 0;
- foreach (int n in usernumbers)
- {
- if (!checkIfUnique(randomnumbers, n))
- {
- score += 1;
- }
- else
- {
- score += 0;
- }
- }
- Console.WriteLine("Your score: {0}", score);
- goto start;
- }
- public static bool checkIfUnique(int[] usernumbers, int input)
- {
- foreach (int n in usernumbers)
- {
- if (input == n)
- {
- return false;
- }
- }
- return true;
- }
- public static int askForInt()
- {
- int input = 0;
- nrplease:
- try
- {
- input = Convert.ToInt32(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.WriteLine("Please only use numbers.");
- goto nrplease;
- }
- return input;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement