Question
C++ #include #include using namespace std; class InvBin { private: string description; int qty; public: InvBin(string d=empty, int q =0) { description = d; q
C++
#include #include using namespace std;
class InvBin { private: string description; int qty; public: InvBin(string d="empty", int q =0) { description = d; q = qty; } void setDescriptio(string d) { description = d; } string getDescription() { return description; } void setQty(int q) { qty = q; } int getQty() { return qty; } };
class BinManager { private: InvBin bin[30]; int numBins; int getIndex(string itemDescription) { for(int i =0; i { if(bin[i].getDescription() == itemDescription) { return i; } return -1; } } public: BinManager() { numBins = 0; } BinManager(int size, string d[], int q[]) { for(int i = 0, i { bin[i].setDescriptive(d[i]); bin[i].setQty(q[i]); } numBins = size; } string getDescription(int index) { return bin[index].getQty(); } string displayAllBins() { string s = ""; for(int i = 0; i < numBins; i++) { s += "\t" + bin[i].getDescription() + " "; return s; } } bool addParts(int binIndex, int q) { if(q < 1) { return false; }else{ bin[binIndex].setQty(bin[binIndex].getQty()+q); return true; } } bool removeParts(int binIndex, int q) { if(q < 1) { return false; } if(bin[binIndex].getQty()< q) { return false; }else{ bin[binIndex].setQty(bin[binIndex].getQty() -q); return true; } } bool addParts(int binIndex, int q) { if(q < 1) { return false; }else{ int index = getIndex(itemDescription); if(index == -1) { return false; }else{ bin[index].setQty(bin[index].getQty()+ q); return true; } } } bool removeParts(int binIndex, int q) { if(q < 1) { return false; }else{ int index = getIndex(itemDescription); if(index == -1) { return false; }else{ if(bin[index].getQty() < q) { return false; bin[index].setQty(bin[index].getQty() -q); return true; } } } } int getQuantity(string itemDescription) { int index = getIndex(itemDescription); if(index != -1) { return bin[index].getQty(); }else{ return -1; } } }; void menu() { cout << "\t1. Get Description" << endl; cout << "\t2. Get Quantity" << endl; cout << "\t3. Add Parts" << endl; cout << "\t4. Remove Parts" << endl; cout << "\t5. Exit" << endl; cout << "\tEnter your choice: " << endl; } int main() { int size = 9; string d[] ={"Regular pliers", "N. nose pliers", "screwdriver", "P. head screw driver", "Wrench-large", "Wrench-small", "Drill", "Cordless drill", "Hand saw"}; int q[] = {25, 5, 25, 6, 7, 18, 51, 16, 12}; BinManager bm(size, d, q); int choice; while(true) { system("cls"); cout << "Bins: "; cout << bm.displayAllBins(); cout << " Menu: "; menu(); cin >> choice; if(choice == 5) { break; int index, qan; string des; switch(choice) { case 1: cout << " Enter bin index: "; cin >> index; while(index < 1 || index > 9) { cout << "Invalid index "; cout << "Re-enter valid range(1-9): "; cin >> index; } cout << bm.getDescription(index - 1) << endl; break; case 2: cout << " Enter item name: "; cin.ignore(); getline(cin, des, ' '); qan = bm.getQuantity(des); if(qan == -1) { cout << "Can not find bin" << des << endl; }else{ cout <<"Quantity: " << bm.getQuantity(des) << endl; break; } case 3: cout << " Enter item name: "; cin.ignore(); getline(cin, des, ' '); qan = bm.getQuantity(des); if(qan == -1) { cout << "Can not find the bin " << des << endl; }else{ cout << "Quantity value should be greater than one" << endl; } break; case 4: cout << " Enter item name: "; cin.ignore(); getline(cin, des, ' '); qan = bm.getQuantity(des); if(qan == -1) { cout << "Can not find the bin" << des << endl; }else{ cout << "Quantity: " << bm.getQuantity(des) << endl; cout << " Enter quantity to remove: "; cin >> qan; if(bm.removeParts(des, qan)) { cout << "Update Quantity: " << bm.getQuantity(des) << endl;; }else{ cout << "Quantity value should be greater than one" << endl; } } break; default: cout << "Invalid choice" << endl; } cout << endl; system("pause"); } } }
I'm getting the following errors please help.
main.cpp:119:10: error: bool BinManager::addParts(int, int) cannot be overloaded
bool addParts(int binIndex, int q)
main.cpp:92:10: error: with bool BinManager::addParts(int, int)
bool addParts(int binIndex, int q)
main.cpp:136:10: error: bool BinManager::removeParts(int, int) cannot be overloaded
bool removeParts(int binIndex, int q)
main.cpp:103:10: error: with bool BinManager::removeParts(int, int)
bool removeParts(int binIndex, int q)
main.cpp: In constructor BinManager::BinManager(int, std::string*, int*):
main.cpp:69:25: error: expected ; before < token
for(int i = 0, i main.cpp:69:25: error: expected primary-expression before < token main.cpp:69:35: error: expected ; before ) token for(int i = 0, i main.cpp:71:20: error: class InvBin has no member named setDescriptive bin[i].setDescriptive(d[i]); main.cpp: In member function std::string BinManager::getDescription(int): main.cpp:79:33: error: could not convert ((BinManager*)this)->BinManager::bin[index].InvBin::getQty() from int to std::string {aka std::basic_string} return bin[index].getQty(); main.cpp: In member function bool BinManager::addParts(int, int): main.cpp:125:34: error: itemDescription was not declared in this scope int index = getIndex(itemDescription); main.cpp: In member function bool BinManager::removeParts(int, int): main.cpp:142:34: error: itemDescription was not declared in this scope int index = getIndex(itemDescription); main.cpp: In function int main(): main.cpp:269:47: error: no matching function for call to BinManager::removeParts(std::string&, int&) if(bm.removeParts(des, qan)) main.cpp:103:10: note: candidate: bool BinManager::removeParts(int, int) bool removeParts(int binIndex, int q) main.cpp:103:10: note: no known conversion for argument 1 from std::string {aka std::basic_string} to int
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started