Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var credit = 0;
- function main_menu(){ //the main menu of the vending machine
- console.log('#-*-*-*-*-*-*-*-*-*-#');
- console.log(' Main Menu');
- console.log('|-*-*-*-*-*-*-*-*-*-|');
- console.log(' Credit'+ credit);
- console.log('#-*-*-*-*-*-*-*-*-*-#');
- for (var idx = 0; idx < options.length; idx++) {
- console.log(idx + ': ' + options[idx]);
- }
- var choice = readline.question('Choice: ');
- if(choice == 0){
- console.log('You chose option ' + choice);
- products_menu();
- }
- if(choice == 1){
- add_credit();
- }
- if(choice == 2){
- refund();
- }
- }
- function add_credit(){
- var add = readline.question('How much credit would you like to add?: ');
- credit += add_credit;
- console.log('You added ' + add);
- main_menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement