コード例 #1
0
ファイル: VMControl.cs プロジェクト: alex606/cis501
 /// <summary>
 /// Controller Class constructor
 /// </summary>
 /// <param name="AD"></param>
 /// <param name="PL"></param>
 /// <param name="NCL"></param>
 /// <param name="SOL"></param>
 public VMControl(AmountDisplay AD, Light[] PL, TimerLight NCL,  Light[] SOL)
 {
     _ad = AD;
     _purchaseLights = PL;
     _noChangelight = NCL;
     _soldOutLights = SOL;
 }
コード例 #2
0
ファイル: Can.cs プロジェクト: alex606/cis501
 public Can(int price, int numCans, string name, 
     CanDispenser canDispenser, VMControl total, Light purchaseLight, Light SoldOutLight)
 {
     _price = price;
     _numCans = numCans;
     _initCans = numCans;
     _canName = name;
     _canDispenser = canDispenser;
     _total = total;
     _purchaseLight = purchaseLight;
     _SoldOutLight = SoldOutLight;
 }
コード例 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            amountDisplay = new AmountDisplay(txtAmount);

            displayNum10Yen = new DebugDisplay(txtNum10Yen);
            displayNum50Yen = new DebugDisplay(txtNum50Yen);
            displayNum100Yen = new DebugDisplay(txtNum100Yen);
            displayNum500Yen = new DebugDisplay(txtNum500Yen);
            displayPrice0 = new DebugDisplay(txtPrice0);
            displayPrice1 = new DebugDisplay(txtPrice1);
            displayPrice2 = new DebugDisplay(txtPrice2);
            displayPrice3 = new DebugDisplay(txtPrice3);
            displayName0 = new DebugDisplay(txtName0);
            displayName1 = new DebugDisplay(txtName1);
            displayName2 = new DebugDisplay(txtName2);
            displayName3 = new DebugDisplay(txtName3);
            displayNumCans0 = new DebugDisplay(txtNumCan0);
            displayNumCans1 = new DebugDisplay(txtNumCan1);
            displayNumCans2 = new DebugDisplay(txtNumCan2);
            displayNumCans3 = new DebugDisplay(txtNumCan3);

            soldOutLight0 = new Light(pbxSOLight0, Color.Orange);
            soldOutLight1 = new Light(pbxSOLight1, Color.Orange);
            soldOutLight2 = new Light(pbxSOLight2, Color.Orange);
            soldOutLight3 = new Light(pbxSOLight3, Color.Orange);

            noChangeLight = new TimerLight(pbxNoChange, Color.Red, timer1);

            purchasableLight0 = new Light(pbxPurLight0, Color.Aqua);
            purchasableLight1 = new Light(pbxPurLight1, Color.Aqua);
            purchasableLight2 = new Light(pbxPurLight2, Color.Aqua);
            purchasableLight3 = new Light(pbxPurLight3, Color.Aqua);

            coinDispenser10Yen = new CoinDispenser(txtChange10Yen);
            coinDispenser50Yen = new CoinDispenser(txtChange50Yen);
            coinDispenser100Yen = new CoinDispenser(txtChange100Yen);
            coinDispenser500Yen = new CoinDispenser(txtChange500Yen);

            // All candispensers share the same output textbox for simulation
            canDispenser0 = new CanDispenser(txtCanDispenser, CANNAMES[0]);
            canDispenser1 = new CanDispenser(txtCanDispenser, CANNAMES[1]);
            canDispenser2 = new CanDispenser(txtCanDispenser, CANNAMES[2]);
            canDispenser3 = new CanDispenser(txtCanDispenser, CANNAMES[3]);

            // You must replace the following default constructors with 
            // constructors with arguments (non-default constructors)
            // to pass (set) the first object that ButtonPressed() will
            // visit

            cans = new Can[NUMCANTYPES];
            coins = new List<Coin>();

            controller = new Controller(cans, coins, noChangeLight, amountDisplay);

            cans[0] = new Can(controller, canDispenser0, purchasableLight0, soldOutLight0, CANPRICES[0], NUMCANS[0]);
            cans[1] = new Can(controller, canDispenser1, purchasableLight1, soldOutLight1, CANPRICES[1], NUMCANS[1]);
            cans[2] = new Can(controller, canDispenser2, purchasableLight2, soldOutLight2, CANPRICES[2], NUMCANS[2]);
            cans[3] = new Can(controller, canDispenser3, purchasableLight3, soldOutLight3, CANPRICES[3], NUMCANS[3]);

            coins.Add(new Coin(controller, coinDispenser10Yen, NUMCOINS[0], COINVALUES[0]));
            coins.Add(new Coin(controller, coinDispenser50Yen, NUMCOINS[1], COINVALUES[1]));
            coins.Add(new Coin(controller, coinDispenser100Yen, NUMCOINS[2], COINVALUES[2]));
            coins.Add(new Coin(controller, coinDispenser500Yen, NUMCOINS[3], COINVALUES[3]));


            purchaseButton0 = new PurchaseButton(cans[0]);
            purchaseButton1 = new PurchaseButton(cans[1]);
            purchaseButton2 = new PurchaseButton(cans[2]);
            purchaseButton3 = new PurchaseButton(cans[3]);

            // You must replace the following default constructors with
            // constructors that take armuments to pass the first object that
            // the CoinInserted() will call
            coinInserter10Yen = new CoinInserter(coins[0]);
            coinInserter50Yen = new CoinInserter(coins[1]);
            coinInserter100Yen = new CoinInserter(coins[2]);
            coinInserter500Yen = new CoinInserter(coins[3]);

            coinReturnButton = new CoinReturnButton(controller);

            // Instantiate your entity and control objects
            // Connect these objects

            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #4
0
ファイル: VendingMachine.cs プロジェクト: alex606/cis501
        private void Form1_Load(object sender, EventArgs e)
        {
            amountDisplay = new AmountDisplay(txtAmount);

            displayNum10Yen = new DebugDisplay(txtNum10Yen);
            displayNum50Yen = new DebugDisplay(txtNum50Yen);
            displayNum100Yen = new DebugDisplay(txtNum100Yen);
            displayNum500Yen = new DebugDisplay(txtNum500Yen);
            displayPrice0 = new DebugDisplay(txtPrice0);
            displayPrice1 = new DebugDisplay(txtPrice1);
            displayPrice2 = new DebugDisplay(txtPrice2);
            displayPrice3 = new DebugDisplay(txtPrice3);
            displayName0 = new DebugDisplay(txtName0);
            displayName1 = new DebugDisplay(txtName1);
            displayName2 = new DebugDisplay(txtName2);
            displayName3 = new DebugDisplay(txtName3);
            displayNumCans0 = new DebugDisplay(txtNumCan0);
            displayNumCans1 = new DebugDisplay(txtNumCan1);
            displayNumCans2 = new DebugDisplay(txtNumCan2);
            displayNumCans3 = new DebugDisplay(txtNumCan3);

            soldOutLight0 = new Light(pbxSOLight0, Color.Orange);
            soldOutLight1 = new Light(pbxSOLight1, Color.Orange);
            soldOutLight2 = new Light(pbxSOLight2, Color.Orange);
            soldOutLight3 = new Light(pbxSOLight3, Color.Orange);

            noChangeLight = new TimerLight(pbxNoChange, Color.Red, timer1);

            purchasableLight0 = new Light(pbxPurLight0, Color.Aqua);
            purchasableLight1 = new Light(pbxPurLight1, Color.Aqua);
            purchasableLight2 = new Light(pbxPurLight2, Color.Aqua);
            purchasableLight3 = new Light(pbxPurLight3, Color.Aqua);

            coinDispenser10Yen = new CoinDispenser(txtChange10Yen);
            coinDispenser50Yen = new CoinDispenser(txtChange50Yen);
            coinDispenser100Yen = new CoinDispenser(txtChange100Yen);
            coinDispenser500Yen = new CoinDispenser(txtChange500Yen);

            // All candispensers share the same output textbox for simulation
            canDispenser0 = new CanDispenser(txtCanDispenser, CANNAMES[0]);
            canDispenser1 = new CanDispenser(txtCanDispenser, CANNAMES[1]);
            canDispenser2 = new CanDispenser(txtCanDispenser, CANNAMES[2]);
            canDispenser3 = new CanDispenser(txtCanDispenser, CANNAMES[3]);

            // Instantiate your entity and control objects
            // Connect these objects
            Light[] purchaseLights = { purchasableLight0, purchasableLight1, purchasableLight2, purchasableLight3 };
            Light[] soldOutLights = { soldOutLight0, soldOutLight1, soldOutLight2, soldOutLight3 };

            Total = new VMControl(amountDisplay, purchaseLights, noChangeLight, soldOutLights);

            tenYenCoin = new Coin(COINVALUES[0], NUMCOINS[0], coinDispenser10Yen,Total);
            fiftyYenCoin = new Coin(COINVALUES[1], NUMCOINS[1], coinDispenser50Yen,Total);
            hundredYenCoin = new Coin(COINVALUES[2], NUMCOINS[2],coinDispenser100Yen,Total);
            fiveHundredYenCoin = new Coin(COINVALUES[3], NUMCOINS[3], coinDispenser500Yen,Total);

            // You must replace the following default constructors with
            // constructors with arguments (non-default constructors)
            // to pass (set) the first object that ButtonPressed() will
            // visit

            coke = new Can(CANPRICES[0], NUMCANS[0], CANNAMES[0], canDispenser0, Total, purchasableLight0, soldOutLight0);
            pepsi = new Can(CANPRICES[1], NUMCANS[1], CANNAMES[1], canDispenser1, Total, purchasableLight1, soldOutLight1);
            pepper = new Can(CANPRICES[2], NUMCANS[2], CANNAMES[2], canDispenser2, Total, purchasableLight2, soldOutLight2);
            sprite = new Can(CANPRICES[3], NUMCANS[3], CANNAMES[3], canDispenser3, Total, purchasableLight3, soldOutLight3);

            purchaseButton0 = new PurchaseButton(coke);
            purchaseButton1 = new PurchaseButton(pepsi);
            purchaseButton2 = new PurchaseButton(pepper);
            purchaseButton3 = new PurchaseButton(sprite);

            Can[] Cans = { coke, pepsi, pepper, sprite };
            Coin[] Coins = { tenYenCoin, fiftyYenCoin, hundredYenCoin, fiveHundredYenCoin };

            CanDispenser[] canDispensors = { canDispenser0, canDispenser1, canDispenser2, canDispenser3 };
            CoinDispenser[] coinDispensors = { coinDispenser10Yen, coinDispenser50Yen, coinDispenser100Yen, coinDispenser500Yen };

            Total.initMachine(Coins, Cans, NUMCANS, NUMCOINS);

            // You must replace the following default constructors with
            // constructors that take armuments to pass the first object that
            // the CoinInserted() will call
            coinInserter10Yen = new CoinInserter(tenYenCoin);
            coinInserter50Yen = new CoinInserter(fiftyYenCoin);
            coinInserter100Yen = new CoinInserter(hundredYenCoin);
            coinInserter500Yen = new CoinInserter(fiveHundredYenCoin);

            coinReturnButton = new CoinReturnButton(Total);

            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }