Example #1
0
        //customize the hero with your own stats
        public void customizeHero()
        {
            HeroFactory heroFactory = new HeroFactory();

            myHero = heroFactory.getHero(HeroTypes.Custom);

            int    health = 0, damage = 0, gold = 0;
            string name = "";

            Console.WriteLine("Introduce the name of your hero: ");
            name = Console.ReadLine();

            while (health < 1 || health > 1000)
            {
                Console.WriteLine("Introduce " + name + "'s Health (between 1 to 1000): ");
                health = Convert.ToInt32(Console.ReadLine());
            }


            while (damage < 1 || damage > 100)
            {
                Console.WriteLine("Introduce " + name + "'s Damage (between 1 to 100): ");
                damage = Convert.ToInt32(Console.ReadLine());
            }


            while (gold < 1 || gold > 5000)
            {
                Console.WriteLine("Introduce " + name + "'s Gold (between 1 and 5000): ");
                gold = Convert.ToInt32(Console.ReadLine());
            }

            myHero.Health = health;
            myHero.Damage = damage;
            myHero.Gold   = gold;
            myHero.Name   = name;


            myHero.showStats();
        }
Example #2
0
        //choose iron man/hulk/spiderman
        public void chooseYourHero()
        {
            HeroFactory heroFactory = new HeroFactory();
            int         heroType    = 0;


            while (heroType <= 0 || heroType > Enum.GetNames(typeof(HeroTypes)).Length)
            {
                Console.WriteLine("Choose your favorite hero:\n");
                Console.WriteLine("Iron Man - press 1\n");
                Console.WriteLine("Hulk - press 2\n");
                Console.WriteLine("Spiderman - press 3\n");
                Console.WriteLine("-----------------------\n");
                Console.WriteLine("IronMan has more gold\n");
                Console.WriteLine("Hulk has more health\n");
                Console.WriteLine("Spiderman has more damage\n");

                heroType = Convert.ToInt32(Console.ReadLine());
            }

            myHero = heroFactory.getHero((HeroTypes)(heroType - 1));

            switch (heroType)
            {
            case 1: { Console.WriteLine("Iron Man selected!\n"); break; }

            case 2: { Console.WriteLine("Hulk selected!\n"); break; }

            case 3: { Console.WriteLine("Spiderman selected!\n"); break; }

            default: { Console.WriteLine(); break; }
            }

            Console.WriteLine("Your hero's stats are:");
            myHero.showStats();
        }