コード例 #1
0
ファイル: Program.cs プロジェクト: rusanvaidya/C-Sharp-Basics
        static void Main(string[] args)
        {
            // 3 x 4 array of Items
            Item[,] products = new Item[3, 4];

            products[0, 0] = new SnackItem("Munchy", 7);
            products[0, 1] = new SnackItem("Chetoo", 5);
            products[0, 2] = new SnackItem("Dorito", 3);
            products[0, 3] = new SnackItem("Fritos", 5);

            products[1, 0] = new ChocolateItem("KitKat", 5);
            products[1, 1] = new ChocolateItem("Bounty", 6);
            products[1, 2] = new ChocolateItem("Snicks", 8);
            products[1, 3] = new ChocolateItem("Chocly", 7);

            products[2, 0] = new DrinkItem("CoCola", 2);
            products[2, 1] = new DrinkItem("Fantay", 3);
            products[2, 2] = new DrinkItem("Sprite", 4);
            products[2, 3] = new DrinkItem("Stingy", 4);


            // Passing the products array to the vending machine
            // Aggregation relationship
            VendingMachine myvendy = new VendingMachine(products);

            // Turning on the vending machine
            myvendy.TurnOn();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Item[,] items = new Item[3, 4];

            items[0, 0] = new ChocolateItem("Dairy Milk", 3);
            items[0, 1] = new ChocolateItem("Snickers", 7);
            items[0, 2] = new ChocolateItem("Kitkat", 5);
            items[0, 3] = new ChocolateItem("5Star", 4);

            items[1, 0] = new SnackItem("Cheetos", 2);
            items[1, 1] = new SnackItem("Lays", 3);
            items[1, 2] = new SnackItem("Dorito", 4);
            items[1, 3] = new SnackItem("Haldiram", 5);

            items[2, 0] = new DrinkItem("Coke", 2);
            items[2, 1] = new DrinkItem("Pepsi", 2);
            items[2, 2] = new DrinkItem("Sprite", 3);
            items[2, 3] = new DrinkItem("Frooti", 5);

            VendingMachine vm = new VendingMachine(items);

            vm.PowerOn();
        }