Ejemplo n.º 1
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("Almighty Sword");

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

            Console.WriteLine();

            Axe axe = new Axe("Axe of Doom");

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

            Console.WriteLine();

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

            // Loop through 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();
                }
            }

            StayAlive();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 5
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.");
                }
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            //create an instance of the sword class
            Sword sword = new Sword("Sword of Destiny");

            //equip the sword
            sword.Equip();
            //sell the sword
            sword.Sell();
            //durability takes damage of 20
            sword.Damage(20);

            Console.WriteLine();

            //create an instance of the axe class
            Axe axe = new Axe("Axe of Wonders");

            //equip the axe
            axe.Equip();
            //sell the axe
            axe.Sell();
            //durability takes damage of 10
            axe.Damage(10);

            Console.WriteLine();

            //create an Inventory so that you turn in items
            //this is an "array" of items
            Iitem[] inventory = new Iitem[2];
            inventory[0] = sword;
            inventory[1] = axe;

            //loop through and turn in all quest items
            //create an index and set it to 0 which is less than the number of items in the inventory and increment the index
            for (int index = 0; index < inventory.Length; index++)
            {
                //check items to turn in from the inventory
                IPartOfQuest Items = inventory[index] as IPartOfQuest;
                //make sure the inventory is not empty and has an item in it.
                if (Items != null)
                {
                    Items.TurnIn();
                }
            }
            //await user input
            Console.ReadKey();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Sword sword = new Sword("Sword of Destiny");

            sword.Equip();
            sword.TakeDamage(20);
            sword.Sell();
            sword.TurnIn();
            Console.WriteLine();
            Axe axe = new Axe("Axe of fury");

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

            //Create an Inventory
            IItem[] inventory = new IItem[2];
            inventory[0] = sword;
            inventory[1] = axe;
            Console.WriteLine();

            //Loop through and turn in all quest items
            //You have to case IPartOfQuest using the "as" keyword

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

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

            Console.ReadKey();
        }
Ejemplo n.º 8
0
            static void Main(string[] args)
            {
                // Change to your number of menuitems.
                const int maxMenuItems = 3;
                int       selector     = 0;
                bool      good         = false;

                while (selector != maxMenuItems)
                {
                    Console.Clear();
                    DrawTitle();
                    DrawMenu(maxMenuItems);
                    good = int.TryParse(Console.ReadLine(), out selector);
                    if (good)
                    {
                        switch (selector)
                        {
                        case 1:
                            HeroClass heroClass = new HeroClass("Choose your class then choose your path....");
                            heroClass.ClassPick();
                            break;

                        case 2:
                            HeroBag heroBag = new HeroBag("See the spoils of war!!!..");
                            Sword   sword   = new Sword("Sword of Destiny");
                            sword.Equip();
                            sword.TakeDamage(20);
                            sword.Sell();
                            sword.TurnIn();
                            Console.WriteLine();

                            Axe axe = new Axe("Axe of Distruction");
                            axe.Equip();
                            axe.TakeDamage(20);
                            axe.Sell();

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

                            //loop through and turn in all quest items
                            for (int i = 0; i < inventory.Length; i++)
                            {
                                IPartOfQuest questItem = inventory[i] as IPartOfQuest;
                                if (questItem != null)
                                {
                                    Console.WriteLine();
                                    questItem.TurnIn();
                                }
                            }
                            Console.ReadKey();
                            break;

                        // possibly more cases here
                        default:
                            if (selector != maxMenuItems)
                            {
                                ErrorMessage();
                            }
                            break;
                        }
                    }
                    else
                    {
                        ErrorMessage();
                    }
                    Console.ReadKey();
                }
            }