Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Constructor Functions


I need help with this assignment. This application simulates a vending machine that dispenses soft drinks. • If the user clicks one of the money deposit buttons, this application adds the amount to the total deposited and updates the display. • If the user clicks the Refund button, this application displays the amount refunded and resets the amount deposited to zero. • If the user clicks a drink button and it is the last drink in stock, this application disables the button for that drink to indicate that it is out of stock. • If the user clicks a drink button, but the user has not deposited enough money, this application displays how much more money needs to be deposited to purchase the drink. • If the user clicks a drink button, and the user has deposited enough money, this application displays a message to enjoy the drink. In addition, if the user has deposited too much money, this application displays how much change is being returned. Specifications • The drinks cost $0.75. • When this application is started, the vending machine has 2 of each drink in stock, and the buttons for all drinks are enabled. Attachments Tags


Constructor Functions - Solution


This is the updated version of your assignment, where constructor and prototypes are been used. Attachments (2 K) Download

button --> <label>&nbsp;</label> <input type="button" id="coke" value="Coke" onClick="VendingMachine.prototype.sellItem(this)"/> <!--"this" represents the button itself or whatever the object is--> <label>&nbsp;</label> <input type="button" id="dietCoke" value="Diet Coke" onClick="VendingMachine.prototype.sellItem(this)"/> <label>&nbsp;</label> <input type="button" id="dew" value="Mountain Dew" onClick="VendingMachine.prototype.sellItem(this)"/> <label>&nbsp;</label> <input type="button

Purchase Answer