Beispiel #1
0
        static void Main(string[] args)
        {
            Sword mySword = new Sword("Big Golden Sword");

            mySword.Equip();
            mySword.TakeDamage(5);
            mySword.Sell();


            Axe myAxe = new Axe("Small Silver Axe");

            myAxe.Equip();

            IItem[] inventory = new IItem[2];

            inventory[0] = mySword;
            inventory[1] = myAxe;

            for (int i = 0; i < inventory.Length; i++)
            {
                IPartOfQuest questItem = inventory[i] as IPartOfQuest;

                if (questItem != null)
                {
                    questItem.TurnIn();
                }
            }



            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Sword sword = new Sword("Sword of Destiny");

            sword.Equip();
            sword.TakeDamage(20);
            sword.Sell();

            Console.WriteLine("--------------------------------------------------------------");

            Axe axe = new Axe("Fury Axe");

            axe.Equip();
            axe.TakeDamage(10);
            axe.Sell();

            Console.WriteLine();

            //create an inventory
            IItem[] inventory = new IItem[2];
            inventory[0] = sword;
            inventory[1] = axe;

            //loop trough and turn in all quest items
            for (int i = 0; i < inventory.Length; i++)
            {
                IPartOfQuest questItem = inventory[i] as IPartOfQuest;
                if (questItem != null)
                {
                    questItem.TurnIn();
                }
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Sword sword = new Sword("Sword of Destiny");

            sword.Equip();
            sword.TakeDamage(20);
            sword.Sell();
            sword.TurnIn();

            Axe axe = new Axe("Fury Axe");

            axe.Equip();
            axe.TakeDamage(10);
            axe.Sell();

            // Create inventory
            Iitem[] inventory = new Iitem[2];
            inventory[0] = sword;
            inventory[1] = axe;

            for (int i = 0; i < inventory.Length; i++)
            {
                IpartOfQuest questItem = inventory[i] as IpartOfQuest;
                if (questItem != null)
                {
                    questItem.TurnIn();
                }
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Sword sword = new Sword("Sword of Destiny");

            sword.Equip();
            sword.TakeDamage(20);
            sword.Sell();

            Axe axe = new Axe("Plain Axe");

            axe.Equip();
            axe.TakeDamage(15);
            axe.Sell();

            //Create an inventory
            IItem[] inventory = new IItem[2];
            inventory[0] = sword;
            inventory[1] = axe;

            //Loop througn and turn in all quest items
            for (int i = 0; i < inventory.Length; i++)
            {
                IPartOfQuest questItem = inventory[i] as IPartOfQuest;
                if (questItem != null)
                {
                    questItem.TurnIn();
                }
            }
        }
Beispiel #5
0
                static void Main(string[] args)
                {
                    Sword sword = new Sword("Sword of Destiny");
                    sword.Equip();
                    sword.TakeDamage(20);
                    sword.Sell();

                    Axe axe = new Axe("Axe of fury");
                    axe.Equip();
                    axe.TakeDamage(20);
                    axe.Sell();
                }
Beispiel #6
0
        public static void Main(string[] args)
        {
            // Create a golden sword and name it
            Sword goldSword = new Sword("Golden Sword");

            goldSword.Equip();
            goldSword.TakeDamage(20);
            goldSword.Sell();

            Console.WriteLine("\n------------------------\n");

            // Create a steal sword and name it
            Sword steelSword = new Sword("Steel Sword");

            steelSword.Equip();
            steelSword.Sell();

            Console.WriteLine("\n------------------------\n");

            // Create an Axe
            Axe axeOfAwesome = new Axe("Axe of Awesome");

            axeOfAwesome.Equip();
            axeOfAwesome.TakeDamage(10);
            axeOfAwesome.Sell();


            // Create an Inventory
            Console.WriteLine("\n\n------------INVENTORY------------\n");

            IItem[] inventory = new IItem[3];
            inventory[0] = goldSword;
            inventory[1] = axeOfAwesome;
            inventory[2] = steelSword;

            // Loop through and turn in all eligible quest items
            for (int i = 0; i < inventory.Length; i++)
            {
                // Store the quest item as an IPartOfQuest if it is possible, if it isn't, it will be null
                IPartOfQuest questItem = inventory[i] as IPartOfQuest;

                if (questItem != null)
                {
                    questItem.TurnIn();
                }
                else
                {
                    Console.WriteLine("Not turned in because item isn't a quest item.");
                }
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            var sword = new Sword("Sword of Destiny");
            sword.Equip();
            sword.Damage(30);
            sword.Sell();

            WriteLine();

            var axe = new Axe("Fury Axe");
            axe.Equip();
            axe.Damage(50);
            axe.Sell();

            WriteLine();

            // Create an inventory based on IItem which allows us
            // to store both swords and axes
            IItem[] inventory = new IItem[2];
            inventory[0] = sword;
            inventory[1] = axe;

            // Here we only turn in items if they implemented IPartOfQuest
            for (var i = 0; i < inventory.Length; i++)
            {
                IPartOfQuest questItem = inventory[i] as IPartOfQuest;
                if (questItem != null)
                {
                    questItem.TurnIn();
                }
            }

            ReadLine();
        }