I have a programming assignment I've been having a lot of trouble with. Here is the question. Its long, I know.
Design and write an object-oriented program for managing inventory bins in a warehouse. To do this you will use tow classes: InvBin and BinManager. The InvBin class holds information about a single bin. The BinManager class will own and manage an array of InvBin objects. Once you have created thses two classes, wirte a menu driven client program that uses a BinManager object to manage its warehouse bins. It should initialize it to use 9 of the bins, holding the following data. The bin index where the item will be stored is also showed here.
1. Regular pliers 25
2. N. nose pliers 5
3. screwdriver 25
4. P.head screw driver 6
5. Wrench-large 7
6. Wrench-small 18
7. Drill 51
Using the BinManager objecgt to help it, the modular client program should display the current bin data, then call functions to display a menu, get and validate the user's choice, and carry out the necessary activities to handle that choice. From looking at the public member functions that the BinManager class provides, it should be clear what options to include in the menu. When the user chooses the "Quit" option from the menu, the program should display the day's final bin information. All I/O should be done in the client class. The BinManager class only accepts information, keeps the array of InvBin objects up to date, and returns information to the client program.
Input validation in the client class: The entered menu choice must be valid
Input validation in the BinManager class: Do not accept numbers less than 1 for the number of parts being added or removed from a bin. Do not allow the user to remove more items from a bin than it currently holds.
Here is what I have so far:
#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;
}
Any help would be appreciated. Thanks.