Classes and Data Abstraction (Object Oriented Design)
$15-20 USD
Completed
Posted about 22 years ago
$15-20 USD
Paid on delivery
Classes and Data Abstraction (Object Oriented Design) Modify the following program so that the candy machine performs the following: 1. Continue asking the user to deposit enough money till it reaches the selling price (the current program asks the user twice to put additional money and if the user doesn't put enough, the machine stops asking him and take the money) 2. Return change if there is any. (The current program doesn't return any change) I will email the whole program to the winner. The main program: (partial) // Main program: #include #include "candy.h" using namespace std; void showSelection(); void sellProduct(dispenserType& item, cashRegister& pCounter); int main() { cashRegister counter; dispenserType candy(100,50); dispenserType chips(100,65); dispenserType gum(75, 45); dispenserType cookies(100,85); int choice; // variable to hold the selection showSelection(); cin>>choice; while(choice != 9) { switch(choice) { case 1: sellProduct(candy, counter); break; case 2: sellProduct(chips, counter); break; case 3: sellProduct(gum, counter); break; case 4: sellProduct(cookies, counter); break; default: cout<<"Bad Selection"<<endl; }//end switch showSelection(); cin>>choice; }//end while return 0; }//end main void showSelection() { cout<<"*** Welcome to Shelly's Candy Shop ***"<<endl; cout<<"To select an item, enter "<<endl; cout<<"1 for Candy"<<endl; cout<<"2 for Chips"<<endl; cout<<"3 for Gum"<<endl; cout<<"4 for Cookies"<<endl; cout<<"9 to exit"<<endl; }//end showSelection void sellProduct(dispenserType& item, cashRegister& pCounter) { int amount; // variable to hold the amount entered int amount2; // variable to hold extra amount needed if([login to view URL]() > 0) //if dispenser is not empty { cout<<"Please deposit "<<[login to view URL]() <<" cents"<<endl; cin>>amount; if(amount < [login to view URL]()) { cout<<"Please deposite another " <<[login to view URL]() - amount<<" cents"<<endl; cin>>amount2; amount = amount + amount2; } if(amount >= [login to view URL]()) { [login to view URL](amount); [login to view URL](); cout<<"Collect item at the bottom and enjoy"<<endl; } else cout<<"Not enough amount. Collect what you deposited."<<endl; cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*
## Deliverables
Fuull documentation for the modified part. Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased.
## Platform
The program must work on Visual C++ and be a Win32 Console Application and C++ header.