コード例 #1
0
        public static void Main(string[] args)
        {
            var name  = Console.ReadLine();
            var level = int.Parse(Console.ReadLine());

            DarkKnight hero = new DarkKnight(name, level);

            Console.WriteLine(hero);
        }
コード例 #2
0
        public static void Main()
        {
            MuseElf    elf    = new MuseElf("Elf", 300);
            DarkKnight knight = new DarkKnight("Knight", 500);
            SoulMaster wizard = new SoulMaster("Wizard", 800);

            System.Console.WriteLine(elf);
            System.Console.WriteLine(knight);
            System.Console.WriteLine(wizard);
        }
コード例 #3
0
ファイル: StartUp.cs プロジェクト: ivaKozarova/CSharpOOP
        public static void Main(string[] args)
        {
            Hero hero = new Hero("pesho", 23);

            Console.WriteLine(hero);
            Elf        elf    = new Elf("Margaritka", 75);
            DarkKnight knight = new DarkKnight("Lord pesho", 45);

            Console.WriteLine(elf);
            Console.WriteLine(knight);
        }
コード例 #4
0
        public static object CreateAHero(string type, string username, int level)
        {
            object hero;

            switch (type.ToLower())
            {
            case "elf":
                hero = new Elf(username, level);
                break;

            case "museelf":
                hero = new MuseElf(username, level);
                break;

            case "wizard":
                hero = new Wizard(username, level);
                break;

            case "darkwizard":
                hero = new DarkWizard(username, level);
                break;

            case "soulmaster":
                hero = new SoulMaster(username, level);
                break;

            case "knight":
                hero = new Knight(username, level);
                break;

            case "darkknight":
                hero = new DarkKnight(username, level);
                break;

            case "bladeknight":
                hero = new BladeKnight(username, level);
                break;

            default:
                throw new InvalidOperationException("The type of the hero that you are trying to enter does not exist.");
            }

            return(hero);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Elf         elf         = new Elf("Elf", 22);
            Knight      knight      = new Knight("Knight", 20);
            Wizard      wizard      = new Wizard("Wizard", 21);
            MuseElf     museElf     = new MuseElf("MuseElf", 23);
            DarkWizard  darkWizard  = new DarkWizard("darkWizard", 24);
            DarkKnight  darkKnight  = new DarkKnight("darkKnight", 25);
            SoulMaster  soulMaster  = new SoulMaster("soulMaster", 26);
            BladeKnight bladeKnight = new BladeKnight("bladeKnight", 27);


            Console.WriteLine(elf);
            Console.WriteLine(knight);
            Console.WriteLine(wizard);
            Console.WriteLine(museElf);
            Console.WriteLine(darkWizard);
            Console.WriteLine(darkKnight);
            Console.WriteLine(soulMaster);
            Console.WriteLine(bladeKnight);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            DarkKnight darkNight = new DarkKnight("knighti", 5);

            Console.WriteLine(darkNight);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var pesho = new DarkKnight("pesho", 12);

            Console.WriteLine(pesho);
        }