Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine object that performs the following operations: Purchases input number of drinks Restocks input number of bottles Reports inventory main.cpp #include #include "VendingMachine.h" using namespace std; int main() { /* Type your code here */ } VendingMachine.h #ifndef VENDINGMACHINE_H_ #define VENDINGMACHINE_H_ #include using namespace std; class VendingMachine { public: VendingMachine(); void Purchase(int amount); int GetInventory(); void Restock(int amount); void Report(); private: int bottles; }; #endif VendingMachine.cpp #include #include #include "VendingMachine.h" using namespace std; VendingMachine::VendingMachine() { bottles = 20; } void VendingMachine::Purchase(int amount) { bottles = bottles - amount; } int VendingMachine::GetInventory() { return bottles; } void VendingMachine::Restock(int amount) { bottles = bottles + amount; } // set the random number generator seed for testing void VendingMachine::Report() { cout << "Inventory: " << bottles << " bottles" << endl; }
Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine object that performs the following operations:
- Purchases input number of drinks
- Restocks input number of bottles
- Reports inventory
#include <iostream>
#include "VendingMachine.h"
using namespace std;int main() {
VendingMachine.h
/* Type your code here */
}#ifndef VENDINGMACHINE_H_
#define VENDINGMACHINE_H_#include <iostream>
using namespace std;class VendingMachine {
public:
VendingMachine();
void Purchase(int amount);
int GetInventory();
void Restock(int amount);
void Report();private:
int bottles;
};#endif
VendingMachine.cpp#include <iostream>
#include <string>#include "VendingMachine.h"
using namespace std;
VendingMachine::VendingMachine() {
bottles = 20;
}void VendingMachine::Purchase(int amount) {
bottles = bottles - amount;
}int VendingMachine::GetInventory() {
return bottles;
}
void VendingMachine::Restock(int amount) {
bottles = bottles + amount;
}// set the random number generator seed for testing
void VendingMachine::Report() {
cout << "Inventory: " << bottles << " bottles" << endl;
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









