コード例 #1
0
        public void Start()
        {
            string userInput;

            do
            {
                Console.WriteLine("Welcome! What would you like to do today?");

                //Options
                Console.WriteLine("[0] Create a hero\n[1] Get all heroes");
                userInput = Console.ReadLine();
                switch (userInput)
                {
                case "0":
                    Hero newHero = GetHeroDetails();
                    HeroBL.AddHero(newHero);
                    Console.WriteLine($"Hero {newHero.Name} was created with a superpower of {newHero.superPowers.Peek()}");
                    break;

                case "1":
                    List <Hero> allHeroes = HeroBL.GetAllHeroes();
                    foreach (var hero in allHeroes)
                    {
                        Console.WriteLine($"Hero {hero.Name}");
                    }
                    break;
                }
            } while (!userInput.Equals("0") && !userInput.Equals("1"));
        }
コード例 #2
0
        public void Start()
        {
            string userInput;

            do
            {
                System.Console.WriteLine("Welcome friend! What would you like to do today?");
                System.Console.WriteLine("[0] Create a hero\n[1] Get all heroes\n[x] Exit");
                userInput = System.Console.ReadLine();
                switch (userInput)
                {
                case "0":
                    Hero newHero = GetHeroDetails();
                    heroBL.AddHero(newHero);
                    System.Console.WriteLine($"Hero {newHero.Name} was created with superpower of {Hero.superPowers.Pop()}!");
                    break;

                case "1":
                    List <Hero> allHeroes = heroBL.GetAllHeroes();
                    foreach (var hero in allHeroes)
                    {
                        System.Console.WriteLine($"Hero {hero.Id}: {hero.Name}");
                    }
                    break;

                case "x":
                    System.Console.WriteLine("Have a great day!");
                    break;
                }
            } while (!userInput.Equals("x"));
        }
コード例 #3
0
        public void Start()
        {
            string userInput;

            do
            {
                System.Console.WriteLine("Welcome Friend! What would you like to do today?");
                //Options
                System.Console.WriteLine("[0] Create a hero \n[1] Get all heroes \n[2] Exit");
                userInput = System.Console.ReadLine();
                switch (userInput)
                {
                case "0":
                    Hero newHero = GetHeroDetails();
                    heroBL.AddHero(newHero);
                    System.Console.WriteLine($"Hero {newHero.Name} was created with a superpower of {Hero.superPowers.Pop()}");
                    break;

                case "1":
                    List <Hero> allheroes = heroBL.GetAllHeroes();
                    foreach (var hero in allheroes)
                    {
                        System.Console.WriteLine($"Hero {hero.Name}");
                    }
                    break;

                case "2":
                    System.Console.WriteLine("Goodbye friend.");
                    break;

                default:
                    System.Console.WriteLine("Invalid input! Please select a valid option!");
                    break;
                }
            } while (!userInput.Equals("2"));
        }