MODIFY THE CODE BELOW SO THAT IT COINCIDES WITH THE RUBRIC ABOVE
H file
#ifndef COKEMACHINE_H_INCLUDED
#define COKEMACHINE_H_INCLUDED
#include
using namespace std;
class CokeMachine {
private:
string machineName;
int changeLevel,maxChangeCapacity,CokePrice,inventoryLevel,maxinventoryCapacity;
public:
CokeMachine(string machine_name, int Coke_Price, int change_Level, int inventory_Level) {
machineName = machine_name;
CokePrice = Coke_Price;
changeLevel = change_Level;
inventoryLevel = inventory_Level;
maxChangeCapacity = 5000;
maxinventoryCapacity = 100;
}
string getMachineName() {
return machineName;
}
bool buyACoke(int payment) {
if(payment==CokePrice) {
inventoryLevel--;
return true;
}
else if(payment>CokePrice) {
if(changeLevel>=payment-CokePrice) {
changeLevel -= (payment-CokePrice);
inventoryLevel--;
return true;
}
}
return false;
}
int getInventoryLevel() {
return inventoryLevel;
}
int getMaxInventoryCapacity() {
return maxinventoryCapacity;
}
bool incrementInventory(int amountToAdd) {
if(amountToAdd+inventoryLevel>getMaxInventoryCapacity())
return false;
else {
inventoryLevel += amountToAdd;
return true;
}
}
int getChangeLevel() {
return changeLevel;
}
bool incrementChangeLevel(int amountToAdd) {
if(maxChangeCapacity>=amountToAdd+changeLevel) {
changeLevel += amountToAdd;
return true;
}
else
return false;
}
int getMaxChangeCapacity() {
return maxChangeCapacity;
}
int getCokePrice() {
return CokePrice;
}
std::string displayMoney(int amount) const {
std::string dollars{std::to_string(amount / 100)};
std::string cents{std::to_string(std::abs(amount % 100))};
return dollars + "." + (cents.size() == 1 ? "0" : "") + cents;
}
};
#endif // COKEMACHINE_H_INCLUDED
CPP File
#include
#include
#include "CokeMachine.h"
using namespace std;
int menu() {
cout
}
int main() {
CokeMachine MyCokeMachine("CSE 1325 Coke Machine", 50, 500, 100);
int option;
do { cout
menu();
cout
cin>>option;
cout
if(option==1) {
int payment;
cout
cin>>payment;
if(MyCokeMachine.buyACoke(payment)) {
if(payment==MyCokeMachine.getCokePrice())
cout
else {
cout
}
}
else {
if(payment cout
}
else
cout
}
}
else if(option==2) {
int products;
cout
cin>>products;
if(MyCokeMachine.incrementInventory(products))
cout
else {
cout
/*This statement prompts user to try again*/
cout
}
}
else if(option==3) {
int amount;
cout
cin>>amount;
if(MyCokeMachine.incrementChangeLevel(amount)) {
cout
}
else{
cout
/*This statement prompts user to try again*/
cout
}
}
else if(option==4) {
/*the following lines have been completed*/
/*This line shows the current Invetory level*/
/*the call has been made using the object MyCokeMachine as InventoryLevel is a private member*/
cout
/*This line shows the maximim capacityof the inventory*/
/*the call has been made using the object MyCokeMachine as MaxInventoryLevel is a private member*/
cout
/*This line shows the current change level*/
/* the call has been made using the object MyCokeMachine as InventoryLevel is a private member*/
cout
/*This line shows maximum change capcity*/
/*the call has been made using the object MyCokeMachine as InventoryLevel is a private member*/
cout
}
else if(option!=0)
cout
} while(option!=0);
return 0;
}
Thanks I'll be sure to thumps up
Code2.cpp-1 Displays the correct menu and uses a while loop to run different menu options Buy a Coke" menu option asks for payment. Payment is entered in pennics. Member function buyACoke0 is called with paymet Code2.cpp-2 If buyACokeD returns TRUE, then use the value of action to either print 'Here's your Coke and your change of Sx.xx" or print Thank you for the exact chango. Heros your Coke". buyACoka() returns the values for action and change. Change should be a string of Sxox If buyACoke0 returns FALSE, then, based on the value of action, print a message about either insufficient funds or unable to give change or out of Coke or, if action is not recognized, print a message that the Coke machine is out of order, Restock Machine" menu option asks how much inventory to add to the machine. Member function incrementinventory) is called. IFTRUE is returned, then print a message stating machine has been restocked. If FALSE iz returned, then print a message about exceeding machine's capacity, In either case, call member function getinventoryLevelD to print the current inventory level Code2 cpp-5 Add change" menu option asks how much change to add to the machine. Member function incremen:ChangeLevel) is called. If TRUE is returned. then print a message stating the change has been updated. If FALSE is returned, then print a message about exceeding machine's capacity. In either case, call member function getChangelevelO to print the curren: change level Code2.cpp-6 Display Machine Info" menu option calls member functions getinventoryLeve. getMaxinventoryCapacityo. getChangelevel,getMaxChangeCapacity) and getCokePrice) and displays information to screen Code2.cpp 7 Menu has an option to exit the menu gracefully. Code2.cpp only displays the menu, accepts input call the appropriate menu functions and print messages based on values returned by the member functions. Code2.cpp-9 Code2cpp should only display the menu, take uzer input, call member functions and display output bazed on information CokeMachine.h-1 No couts or cins in CokeMachine.h CokeMachine.h-2 function incrementChangeLeveK) verifies that taking payment will not exceed the change max capacity. CokeMachine.h-3 Member function incrementinventory0 verifies that restocking request will not exceed the machine's inventory max Member function displayMoney()properly converts pennies to dollars and cents into a string. displayMoney) is anly called by member functions and is NEVER called from Code2.cpp. All member functions that return change as a string must cal displayMoney() to convert nt change tostring change. string containing dollars and cents should also contain the and decimal point so that money is displayed at xx CokeMachine.h-4 Code2.cpp-1 Displays the correct menu and uses a while loop to run different menu options Buy a Coke" menu option asks for payment. Payment is entered in pennics. Member function buyACoke0 is called with paymet Code2.cpp-2 If buyACokeD returns TRUE, then use the value of action to either print 'Here's your Coke and your change of Sx.xx" or print Thank you for the exact chango. Heros your Coke". buyACoka() returns the values for action and change. Change should be a string of Sxox If buyACoke0 returns FALSE, then, based on the value of action, print a message about either insufficient funds or unable to give change or out of Coke or, if action is not recognized, print a message that the Coke machine is out of order, Restock Machine" menu option asks how much inventory to add to the machine. Member function incrementinventory) is called. IFTRUE is returned, then print a message stating machine has been restocked. If FALSE iz returned, then print a message about exceeding machine's capacity, In either case, call member function getinventoryLevelD to print the current inventory level Code2 cpp-5 Add change" menu option asks how much change to add to the machine. Member function incremen:ChangeLevel) is called. If TRUE is returned. then print a message stating the change has been updated. If FALSE is returned, then print a message about exceeding machine's capacity. In either case, call member function getChangelevelO to print the curren: change level Code2.cpp-6 Display Machine Info" menu option calls member functions getinventoryLeve. getMaxinventoryCapacityo. getChangelevel,getMaxChangeCapacity) and getCokePrice) and displays information to screen Code2.cpp 7 Menu has an option to exit the menu gracefully. Code2.cpp only displays the menu, accepts input call the appropriate menu functions and print messages based on values returned by the member functions. Code2.cpp-9 Code2cpp should only display the menu, take uzer input, call member functions and display output bazed on information CokeMachine.h-1 No couts or cins in CokeMachine.h CokeMachine.h-2 function incrementChangeLeveK) verifies that taking payment will not exceed the change max capacity. CokeMachine.h-3 Member function incrementinventory0 verifies that restocking request will not exceed the machine's inventory max Member function displayMoney()properly converts pennies to dollars and cents into a string. displayMoney) is anly called by member functions and is NEVER called from Code2.cpp. All member functions that return change as a string must cal displayMoney() to convert nt change tostring change. string containing dollars and cents should also contain the and decimal point so that money is displayed at xx CokeMachine.h-4