Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var newWarehouse = new Warehouse("Warehouse1", 101);
            var myItem = newWarehouse.FindAndReturnItem(101);
            Console.WriteLine("My new item is {0}", myItem.Name);

            // Inheritance Example
            var myComputer = new Computer();
            myComputer.ID = 102;

            Item mySecondComputer = new Computer(); // only get properties from Item
            mySecondComputer.ID = 103;
            Computer mySecondComputer2 = mySecondComputer as Computer; // treat AS Computer, get all Computer properties
            mySecondComputer2.CPUType = "i7";
            string myCPUype = mySecondComputer2.CPUType;
            mySecondComputer2.Name = "Jupiter";
            mySecondComputer2.Purchase();

            Software mySoftware = new Software();
            mySoftware.Name = "Foo Software";
            mySoftware.ID = 101;
            mySoftware.ISBN = "1234";
            mySoftware.Purchase();

            // Static Method
            Item newItem = Item.GetItem();
            Console.WriteLine("New item ID = {0}, name = {1}", newItem.ID, newItem.Name);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var newWarehouse = new Warehouse("Warehouse 1", 101);
            var myItem = newWarehouse.FindAndRetunItem(101);
            Console.WriteLine("my new item is " + myItem.Name);

            var myComputer = new Computer();
            myComputer.ID = 102;

            Item mySecondComputer = new Computer();
            mySecondComputer.ID = 103;
            Computer mySecondComputer2 = mySecondComputer as Computer;
            mySecondComputer2.CPUType = "i7";
            string myCPUType = mySecondComputer2.CPUType;
            mySecondComputer2.Name = "Jupiter";

            mySecondComputer2.Purchase();

            Software mySoftware = new Software();
            mySoftware.Name = "Foo";
            mySoftware.ID = 101;
            mySoftware.ISBN = "1234";
            mySoftware.Purchase();

            //Item newItem = Item.GetItem();
            List<Item> myItems = Item.GetItems(20);
            foreach (Item item in myItems)
            {
                Console.WriteLine("New item ID = {0}, name = {1}",
                    item.ID, item.Name);
            }
        }
        static void Main(string[] args)
        {
            //var newWareHouse = new WareHouse("WareHouse1", 101);
            //var myItem = newWareHouse.FindAndReturnItem(101);
            //Console.WriteLine("My new Item is "+ myItem.Name, myItem.ID);

            Computer myComputer = new Computer();
            myComputer.ID = 102;

            Item mySecondComputer = new Computer();
            mySecondComputer.ID = 102;
            Computer mySecondComputer2 = mySecondComputer as Computer;
            mySecondComputer2.CPUType = " iOS 10 El Capitan..";

            //string myCPUType = mySecondComputer2.CPUType;
            //Console.WriteLine(myCPUType);

            mySecondComputer2.Name = "Mercury";

            mySecondComputer2.Purchase();

            Software mySoftware = new Software();
            mySoftware.ISBN = "1234";
            mySoftware.Name = "ios";
            mySoftware.ID = 103;
            mySoftware.Purchase();

            Console.ReadLine();
        }