Question: Write a class called Snack. It should have data members for the name of a snack, the price of the snack (double), and the number

Write a class called Snack. It should have data members for the name of a snack, the price of the snack (double), and the number of calories in the snack (int). The class should have a constructor that takes three parameters and uses them to initialize the data members. It should also have a default constructor that initializes the data members to "bottled water", 1.75 and 0, respectively. The class should have get methods for all three data members. Write a class called VendSlot. It should have two data members - a Snack, and the amount of that Snack that is currently in the slot. It should also have a default constructor that initializes the data members to a default Snack object and 5. The class should have a constructor that takes two parameters and uses them to initialize the data members. It should have get methods for both data members. It should have a method called decrementAmount that decreases the amount by 1. Write a class called MiniVend, which represents a vending machine with four slots. It should have two data members - an array of 4 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 1 to 4) - 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 Snack class:

getName

getPrice

getNumCalories

For the VendSlot class:

getSnack

getAmount

decrementAmount

For the MiniVend class:

getMoney

numEmptySlots

valueOfSnacks

buySnack

For example, these classes could be used as follows:

Write a class called Snack. It should have data members for theThe files must be named Snack.hpp, Snack.cpp, VendSlot.hpp, VendSlot.cpp, MiniVend.hpp, and MiniVend.cpp. 

Snack s10"corn chips 0.75, 200) Snack s20' candy bar 1.25, 300) Snack s3C' beer 2.00, 450) root Vend Slot vs10s1, 2 VendSlot vs20s 2, 1); Vend Slot vs3Cs3, 0D; Vend Slot vs4; five bottles of water MiniVend machine(vs1, vs2, vs3, vs4, 0 stod: cout machine.numEmptystotsO std ::endl; sted: cout machine.value0fSnacksO std: endl; stod: :cout machine.getMoneyO std: endl; machine buySnackC1); stod: cout machine.numEmptystotsO std: :endl; sted: cout machine.value0fSnacksO std: endl; stod: :cout machine.getMoneyO std: endl

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!