コード例 #1
0
 public VendingMachineController(List <Can> cans, List <Coin> coins, TimerLight noChange, AmountDisplay ad)
 {
     this.cans     = cans;
     this.coins    = coins;
     noChangeLight = noChange;
     amtDisplay    = ad;
 }
コード例 #2
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;
 }
コード例 #3
0
 /// <summary>
 /// Creates instance of this contoller
 /// </summary>
 /// <param name="drinks">List of drinks for controller to access</param>
 /// <param name="coins">Array of coins for controller to access</param>
 /// <param name="amountDisplay">Device for controller to display the amount of money inserted.</param>
 /// <param name="noChange">Light for contoller to indicate if change cannot be made.</param>
 public MachineControl(List <Drink> drinks, Coin[] coins, AmountDisplay amountDisplay, TimerLight noChange)
 {
     moneyInserted      = 0;
     this.drinks        = drinks;
     this.coins         = coins;
     this.amountDisplay = amountDisplay;
     this.noChange      = noChange;
 }
コード例 #4
0
 /// <summary>
 /// constructor for Vending Control
 /// </summary>
 /// <param name="CoinArray"></param>
 /// <param name="BeverageArray"></param>
 /// <param name="NoChangeLight"></param>
 /// <param name="AmntDisplay"></param>
 public VendingControl(Coin[] CoinArray, Beverage[] BeverageArray, TimerLight NoChangeLight, AmountDisplay AmntDisplay)
 {
     this.CoinArray     = CoinArray;
     this.BeverageArray = BeverageArray;
     this.NoChangeLight = NoChangeLight;
     this.AmtDisplay    = AmntDisplay;
     credit             = 0;
 }
コード例 #5
0
 /// <summary>
 /// constructor for purchasing
 /// </summary>
 /// <param name="canArr">the array of cans</param>
 /// <param name="coinArr">the array of coins</param>
 /// <param name="changeLight">the no change light</param>
 /// <param name="AmoD">the display for the money in the machine</param>
 public Purchasing(Can[] canArr, Coin[] coinArr, TimerLight changeLight, AmountDisplay AmoD)
 {
     _totalEntered = 0;
     cans          = canArr;
     coins         = coinArr;
     timerL        = changeLight;
     amountD       = AmoD;
 }
コード例 #6
0
        public Controller(Can[] cans, List <Coin> coins, TimerLight noChangeLight, AmountDisplay amountDisplay)
        {
            this.cans          = cans;
            this.coins         = coins;
            this.noChangeLight = noChangeLight;
            this.amountDisplay = amountDisplay;

            amount = 0;
        }
コード例 #7
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
            CoinArray[0] = new Coin(COINVALUES[0], NUMCOINS[0], coinDispenser10Yen);
            CoinArray[1] = new Coin(COINVALUES[1], NUMCOINS[1], coinDispenser50Yen);
            CoinArray[2] = new Coin(COINVALUES[2], NUMCOINS[2], coinDispenser100Yen);
            CoinArray[3] = new Coin(COINVALUES[3], NUMCOINS[3], coinDispenser500Yen);

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


            VendControl = new VendingControl(CoinArray, BeverageArray, noChangeLight, amountDisplay);
            //these constructors will take the VendingController object
            purchaseButton0 = new PurchaseButton(VendControl, 0);
            purchaseButton1 = new PurchaseButton(VendControl, 1);
            purchaseButton2 = new PurchaseButton(VendControl, 2);
            purchaseButton3 = new PurchaseButton(VendControl, 3);

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

            coinReturnButton = new CoinReturnButton(VendControl);



            // Display debug information
            displayCanPricesAndNames();
#if DEBUG
            updateDebugDisplays();
#endif
        }
コード例 #8
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]);

            coinReturnButton = new CoinReturnButton(this);

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

            coinsInserted[0] = new Coin(COINVALUES[0], NUMCOINS[0], coinDispenser10Yen);
            coinsInserted[1] = new Coin(COINVALUES[1], NUMCOINS[1], coinDispenser50Yen);
            coinsInserted[2] = new Coin(COINVALUES[2], NUMCOINS[2], coinDispenser100Yen);
            coinsInserted[3] = new Coin(COINVALUES[3], NUMCOINS[3], coinDispenser500Yen);

            // You must replace the following default constructors with
            // constructors with arguments (non-default constructors)
            // to pass (set) the first object that ButtonPressed() will
            // visit
            purchaseButton0 = new PurchaseButton(products[0]);
            purchaseButton1 = new PurchaseButton(products[1]);
            purchaseButton2 = new PurchaseButton(products[2]);
            purchaseButton3 = new PurchaseButton(products[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(coinsInserted[0]);
            coinInserter50Yen  = new CoinInserter(coinsInserted[1]);
            coinInserter100Yen = new CoinInserter(coinsInserted[2]);
            coinInserter500Yen = new CoinInserter(coinsInserted[3]);



            // Instantiate your entity and control objectst5

            // Connect these objects

            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #9
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]);

            //needed
            _coins.Add(new Money(NUMCOINS[3], COINVALUES[3], coinDispenser500Yen));
            _coins.Add(new Money(NUMCOINS[2], COINVALUES[2], coinDispenser100Yen));
            _coins.Add(new Money(NUMCOINS[1], COINVALUES[1], coinDispenser50Yen));
            _coins.Add(new Money(NUMCOINS[0], COINVALUES[0], coinDispenser10Yen));

            // public Can(string name, int stock, int price, CanDispenser canDispenser, Light purchaseLight, Light soldOutLight)
            _cans.Add(new Can(CANNAMES[0], NUMCANS[0], CANPRICES[0], canDispenser0, purchasableLight0, soldOutLight0));
            _cans.Add(new Can(CANNAMES[1], NUMCANS[1], CANPRICES[1], canDispenser1, purchasableLight1, soldOutLight1));
            _cans.Add(new Can(CANNAMES[2], NUMCANS[2], CANPRICES[2], canDispenser2, purchasableLight2, soldOutLight2));
            _cans.Add(new Can(CANNAMES[3], NUMCANS[3], CANPRICES[3], canDispenser3, purchasableLight3, soldOutLight3));

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



            purchaseButton0 = new PurchaseButton(_economy, 0);
            purchaseButton1 = new PurchaseButton(_economy, 1);
            purchaseButton2 = new PurchaseButton(_economy, 2);
            purchaseButton3 = new PurchaseButton(_economy, 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(_economy, 3);
            coinInserter50Yen  = new CoinInserter(_economy, 2);
            coinInserter100Yen = new CoinInserter(_economy, 1);
            coinInserter500Yen = new CoinInserter(_economy, 0);

            coinReturnButton = new CoinReturnButton(_economy);

            // Instantiate your entity and control objects
            // Connect these objects
            _economy.SetNoChangeLight(noChangeLight);
            _economy.SetLists(_cans, _coins);

            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #10
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



            //purchaseButton0 = new PurchaseButton();
            //purchaseButton1 = new PurchaseButton();
            //purchaseButton2 = new PurchaseButton();
            //purchaseButton3 = new PurchaseButton();

            // 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();
            //coinInserter50Yen = new CoinInserter();
            //coinInserter100Yen = new CoinInserter();
            //coinInserter500Yen = new CoinInserter();

            //coinReturnButton = new CoinReturnButton();

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

            canArr[0] = new Can(120, "Coca-Cola", 4, soldOutLight0, purchasableLight0, canDispenser0, displayNumCans0);
            canArr[1] = new Can(170, "Pepsi", 4, soldOutLight1, purchasableLight1, canDispenser1, displayNumCans1);
            canArr[2] = new Can(130, "Dr.Pepper", 4, soldOutLight2, purchasableLight2, canDispenser2, displayNumCans2);
            canArr[3] = new Can(110, "Sprite", 4, soldOutLight3, purchasableLight3, canDispenser3, displayNumCans3);

            coinArr[0] = new Coin(10, 15, coinDispenser10Yen, displayNum10Yen);
            coinArr[1] = new Coin(50, 10, coinDispenser50Yen, displayNum50Yen);
            coinArr[2] = new Coin(100, 5, coinDispenser100Yen, displayNum100Yen);
            coinArr[3] = new Coin(500, 2, coinDispenser500Yen, displayNum500Yen);
            //Coin[] coinToIOMan = { fiveHundred, oneHundred, fifty, ten };

            total = new InputOutputManager(canArr, coinArr, noChangeLight, amountDisplay);


            coinInserter10Yen  = new CoinInserter(0, total);
            coinInserter50Yen  = new CoinInserter(1, total);
            coinInserter100Yen = new CoinInserter(2, total);
            coinInserter500Yen = new CoinInserter(3, total);
            coinReturnButton   = new CoinReturnButton(total);
            purchaseButton0    = new PurchaseButton(0, total);
            purchaseButton1    = new PurchaseButton(1, total);
            purchaseButton2    = new PurchaseButton(2, total);
            purchaseButton3    = new PurchaseButton(3, total);
            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #11
0
 public void SetNoChangeLight(TimerLight noChangeLight)
 {
     NoChangeLight = noChangeLight;
 }
コード例 #12
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[4] {
                new Can(120, 4, purchasableLight0, soldOutLight0, canDispenser0),
                new Can(170, 4, purchasableLight1, soldOutLight1, canDispenser1),
                new Can(130, 4, purchasableLight2, soldOutLight2, canDispenser2),
                new Can(110, 4, purchasableLight3, soldOutLight3, canDispenser3)
            };

            coins = new Coin[4] {
                new Coin(10, 15, coinDispenser10Yen),
                new Coin(50, 10, coinDispenser50Yen),
                new Coin(100, 5, coinDispenser100Yen),
                new Coin(500, 2, coinDispenser500Yen)
            };

            Purch = new Purchasing(cans, coins, noChangeLight, amountDisplay);

            purchaseButton0 = new PurchaseButton(0, Purch);
            purchaseButton1 = new PurchaseButton(1, Purch);
            purchaseButton2 = new PurchaseButton(2, Purch);
            purchaseButton3 = new PurchaseButton(3, Purch);

            // 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(0, Purch);
            coinInserter50Yen  = new CoinInserter(1, Purch);
            coinInserter100Yen = new CoinInserter(2, Purch);
            coinInserter500Yen = new CoinInserter(3, Purch);

            coinReturnButton = new CoinReturnButton(Purch);

            // Make additional connections

            // Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #13
0
ファイル: VendingMachine.cs プロジェクト: pcjellison/501_P3
        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
            //------------DONE------------------
            purchaseButton0 = new PurchaseButton(drink1);
            purchaseButton1 = new PurchaseButton(drink2);
            purchaseButton2 = new PurchaseButton(drink3);
            purchaseButton3 = new PurchaseButton(drink4);

            // You must replace the following default constructors with
            // constructors that take armuments to pass the first object that
            // the CoinInserted() will call
            //-----------DONE--------------
            coinInserter10Yen  = new CoinInserter(yen10);
            coinInserter50Yen  = new CoinInserter(yen50);
            coinInserter100Yen = new CoinInserter(yen100);
            coinInserter500Yen = new CoinInserter(yen500);



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

            coinInventory[0] = yen10;
            coinInventory[1] = yen50;
            coinInventory[2] = yen100;
            coinInventory[3] = yen500;

            coinReturnButton = new CoinReturnButton(coinInventory);

            drinkInventory[0] = drink1;
            drinkInventory[1] = drink2;
            drinkInventory[2] = drink3;
            drinkInventory[3] = drink4;

            controller = new Controller(coinInventory, drinkInventory);

            //// Display debug information
            displayCanPricesAndNames();
            updateDebugDisplays();
        }
コード例 #14
0
 public VMControl(TimerLight noChangeLight, AmountDisplay amountDisplay)
 {
     this.noChangeLight = noChangeLight;
     this.amountDisplay = amountDisplay;
     totalInsertMoney   = 0;
 }
コード例 #15
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();
        }
コード例 #16
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]);

            //initialize cans
            for (int i = 0; i < 4; i++)
            {
                allProduct[i] = new Can(CANNAMES[i], CANPRICES[i], NUMCANS[i]);
                userMoney[i]  = new Coin(COINVALUES[i], NUMCOINS[i]);
            }

            // You must replace the following default constructors with
            // constructors with arguments (non-default constructors)
            // to pass (set) the first object that ButtonPressed() will
            // visit
            purchaseButton0 = new PurchaseButton(allProduct[0]);
            purchaseButton1 = new PurchaseButton(allProduct[1]);
            purchaseButton2 = new PurchaseButton(allProduct[2]);
            purchaseButton3 = new PurchaseButton(allProduct[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(userMoney[0]);
            coinInserter50Yen  = new CoinInserter(userMoney[1]);
            coinInserter100Yen = new CoinInserter(userMoney[2]);
            coinInserter500Yen = new CoinInserter(userMoney[3]);

            coinReturnButton = new CoinReturnButton(userMoney[0]);

            //add in lights so they can be easily turned on
            allProduct[0].purchaseLight = purchasableLight0;
            allProduct[1].purchaseLight = purchasableLight1;
            allProduct[2].purchaseLight = purchasableLight2;
            allProduct[3].purchaseLight = purchasableLight3;

            allProduct[0].soldOutLight = soldOutLight0;
            allProduct[1].soldOutLight = soldOutLight1;
            allProduct[2].soldOutLight = soldOutLight2;
            allProduct[3].soldOutLight = soldOutLight3;

            allProduct[0].productCanDispenser = canDispenser0;
            allProduct[1].productCanDispenser = canDispenser1;
            allProduct[2].productCanDispenser = canDispenser2;
            allProduct[3].productCanDispenser = canDispenser3;

            CoinDispenser[] tempAllCoinDispensers = { coinDispenser10Yen, coinDispenser50Yen, coinDispenser100Yen, coinDispenser500Yen };
            Coin.AllCoinDispensers = tempAllCoinDispensers;

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