Question: use c++ Write a class called MiniVend, which represents a vending machine with four slots. It should have five data members: four VendSlots and the

use c++

Write a class called MiniVend, which represents a vending machine with four slots. It should have five data members: four VendSlots and the money in the machine. The class should have a constructor that takes 5 parameters - 4 VendSlot objects and the initial money. It should have a get method that returns the amount of money in the machine. It should have a method called numEmptySlots that returns the number of slots that have no Snacks left. It should have a method called valueOfSnacks that returns the total value of the Snacks in the machine. It should have a method called buySnack that takes as a parameter the number of the slot from which to purchase a Snack (from 0 to 3) - if that slot is empty, nothing should happen, otherwise the amount of that Snack should be decremented and the money increased buy the price of the Snack that was selected.

The functions should have the following names:

For the MiniVend class:

getMoney

numEmptySlots

valueOfSnacks

buySnack

For example, these classes could be used as follows:

 MiniVend machine(vs1, vs2, vs3, vs4, 0); std::cout << machine.numEmptySlots() << std::endl; std::cout << machine.valueOfSnacks() << std::endl; std::cout << machine.getMoney() << std::endl; machine.buySnack(1); std::cout << machine.numEmptySlots() << std::endl; std::cout << machine.valueOfSnacks() << std::endl; std::cout << machine.getMoney() << std::endl; 

The files must be named MiniVend.hpp, MiniVend.cpp MiniVendMain.cpp

Please use comments to explain

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!