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(); }
public PurchaseButton(int canN, Purchasing Pur) { canIndex = canN; Purch = Pur; }
// replace the following default constructor with a constructor that takes // an object to be set to the above field public CoinReturnButton(Purchasing Pur) { Purch = Pur; }
// rewrite the following constructor with a constructor that takes an object // to be set to the above field public CoinInserter(int CoinNum, Purchasing Pur) { Purch = Pur; coinIndex = CoinNum; }