Answer:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
class InvBin {
private:
string description;
int qty;
public:
InvBin(){ description = ""; qty = 0;}
InvBin (string d, int q) { description = d; qty = q;}
void setDescription (string d){description = d;}
void setQty(int q){qty = q;}
string getDescription() {return description;}
int getQty(){ return qty; }
};
class BinManager {
private:
InvBin bin[30];
int numBins;
public:
BinManager() {numBins=0;}
BinManager(int size, string d[], int q[])
{
int i;
for(i=0; i<size; ++i)
{
bin[i].setDescription(d[i]);
bin[i].setQty(q[i]);
}
numBins = size;
}
void setDescription (int b, string d) {bin[b].setDescription(d); }
void setQty(int b, int q) { bin[b].setQty(q); }
string getDescription(int b) { return bin[b].getDescription();}
int getQty(int b) { return bin[b].getQty();}
bool addParts(int b, int q)
{
int temp;
if(q < 1)
return false;
else
{
temp = bin[b].getQty() + q;
bin[b].setQty(temp);
return true;
}
}
bool removeParts(int b, int q)
{
int temp;
if (q < 1 || bin[b].getQty() < q)
return false;
else
{
temp = bin[b].getQty() - q;
bin[b].setQty(temp);
return true;
}
string displayAllBins()
{
int i;
for(i=0;i<numBins;++i)
cout << i+1 << ". " << left<< setw(20) << bin[i].getDescription()
<< right << setw(4) << bin[i].getQty() << endl;
}
};
system("PAUSE");
return EXIT_SUCCESS;
}
Explanation: