コード例 #1
0
        static int PlayerChoiceMenu(int chosenCar, List <Car> cars, int checkedCars)
        {
            Console.Clear();
            string[] choices = { "check", "let go" };

            Console.WriteLine("Do you want to check or let the car go?\nCheck or Let Go");

            string playerChoice = Console.ReadLine();

            playerChoice = Klasser.IsTrueString(choices, playerChoice, "That is not an availalble choice!");

            bool foundContraband;

            if (playerChoice == choices[0])
            {
                foundContraband = cars[chosenCar].Examine();

                if (foundContraband.Equals(true))
                {
                    Klasser.WriteLine("There was a hidden contraband in the car!\nPress Enter", false);
                }
                else
                {
                    Klasser.WriteLine("There were no hidden contraband in the car! You paid the driver 10 dollar\nPress Enter", false);
                }
            }
            else
            {
                cars[chosenCar].AlreadyChecked = true;
                Klasser.WriteLine("You decided to trust the driver!", false);
            }
            return(checkedCars++);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ViktorBakken/Progr-Prov2
        static SuperHero ChooseRace(SuperHero player)
        {
            string[] raceDataBase = { "mutant", "alien", "ritch" }; //The Race database

            string Choice = Console.ReadLine();                     //Players

            Klasser.IsTrueString(raceDataBase, Choice, "fel ras");  //Checks if the playes choice is one of the options

            if (Choice.Equals(raceDataBase[0]))                     //Player chose mutant
            {
                player = new Mutant();
            }
            else if (Choice.Equals(raceDataBase[1])) //Player chose Alien
            {
                player = new Alien();
            }
            else if (Choice.Equals(raceDataBase[2])) //Player chose Ritch
            {
                player = new Ritch();
            }
            return(player);
        } //Lets the player choose race