示例#1
0
        static void Main(string[] args)
        {
            Random     rand         = new Random();
            int        day          = 1;
            int        nummerOfCars = 0;
            int        checkedCars  = 0;
            List <Car> cars         = new List <Car>();
            List <Car> resetCars    = new List <Car>()
            {
            };
            List <int> unCheckedCars = new List <int>();
            bool       wantToPlay    = true;

            Console.WriteLine("welcom to border patrol! You will be checking passing cars for contrabands!\nPress Enter");
            Console.ReadLine();

            while (wantToPlay)
            {
                nummerOfCars = rand.Next(1, 10);
                cars         = CreateCars(nummerOfCars, rand, cars);

                Klasser.WriteLine("Day " + day.ToString() + "\n You will check " + nummerOfCars + " cars today!", false);

                while (CheckIfAllCarsAreChecked(cars))
                {
                    PrintUnchecked(cars);

                    int math = nummerOfCars - checkedCars;
                    Console.WriteLine("Which car do you want to check? There are " + math.ToString() + " left out of " + nummerOfCars + "!");

                    string car       = Console.ReadLine();
                    int    chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars) - 1;

                    while (cars[chosenCar].AlreadyChecked.Equals(true))
                    {
                        Console.WriteLine("You have already checked that car!");
                        car       = Console.ReadLine();
                        chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars);
                    }
                    checkedCars = PlayerChoiceMenu(chosenCar, cars, checkedCars);
                    Console.Clear();
                }
                cars = resetCars;
                day++;
            }
        }