/*******************************************************************************
*
* SOME SORT OF TITLE
* ______________________________________________________________________________
*
* This is the the way the description for my code typically
* ______________________________________________________________________________
* INPUT
* input 1 :
* input 2 :
* input 3 :
*
* OUTPUT
* output 2 :
*******************************************************************************/
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;
const unsigned short SIZE = 10;
const unsigned short MAX_INPUT_SIZE = 15;
//Declare Bin Data Type
struct Bin {
enum PartType { VALVE, BEARING, BUSHING, COUPLING, FLANGE, GEAR, GEAR_HOUSING, VACUUM_GRIPPER, CABLE, ROD};
string binNames[SIZE] = {"Valve", "Bearing", "Bushing", "Coupling", "Flange", "Gear", "Gear Housing", "Vacuum Gripper", "Cable", "Rod"};
int binPartCounts[SIZE] = {10, 5, 15, 21, 7, 5, 5, 25, 18, 12};
int binSize = SIZE;
};
struct Menu {
string prompt;
int menuItems;
string errorMessage;
};
void PrintPart(Bin& bin, Bin::PartType part) {
cout << "Part: " << bin.binNames[part] << ", Count: " << bin.binPartCounts[part] << endl;
}
void PrintBin(Bin& bin, int size = SIZE) {
string line = "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
string line2 = "────────────────────────────────────────────────────────────────────────────";
cout << line << endl;
cout << left << setw(35) << " Part Description" << left << setw(35) << "Number of Parts in the Bin" << endl;
cout << line2 << endl;
for (int i; i < size; i++) {
cout << " " << left << setw(34) << bin.binNames[i] << setw(35) << bin.binPartCounts[i] << endl;
}
cout << line << endl;
cout << endl;
}
bool menuValidation(string input, Menu menu){
bool isValid = false;
string placeHolder;
for (int i = 0; i < menu.menuItems; i++){
placeHolder = to_string(i + 1);
if (input == placeHolder) {
isValid = true;
}
}
return isValid;
}
bool partValidation(string input, Bin bin){
bool isValid = false;
for (int i = 0; i < bin.binSize; i++){
if (input == bin.binNames[i]) {
isValid = true;
}
}
return isValid;
}
void AddParts(){
}
void RemoveParts(){
}
int main() {
//Create bin object with the default values
Bin currentBin;
//Create menu for choosing to select a bin
Menu binSelection;
binSelection.prompt = "(1) Select a bin\n(2) Exit\n";
binSelection.menuItems = 2;
binSelection.errorMessage = "Invalid input! Please enter 1 or 2.\n";
//Create menu for choosing a part bin
Menu partSelection;
partSelection.prompt = "Please enter the name of which part bin you would like to modify: \n";
partSelection.menuItems = 1;
partSelection.errorMessage = "Invalid input! Please enter the exact name of a part.\n";
//Create menu for decided what to do with that bin
Menu partModification;
partModification.prompt = "(1) Add parts\n(2) Remove parts\n(3) Select new bin\n(4) Exit\n";
partModification.menuItems = 4;
partModification.errorMessage = "Invalid input! Please enter 1, 2, 3 or 4.\n";
//At the beginning we should print the bin so the user can see what they are modifying
PrintBin(currentBin);
//Delcaring our input variables;
string inputtedPartName;
string menuOption;
//We output the first menu for selecting a bin
cout << binSelection.prompt;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
//Validate the users menu option
while (!menuValidation(menuOption, binSelection)) {
cout << binSelection.errorMessage;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
}
//If we selected 1 we should get the name of the part they want to modfiy
if (menuOption == "1") {
//We now prompt for the part name
cout << partSelection.prompt;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
//Check to see if that part is a name in our bin array
while (!partValidation(menuOption, currentBin)){
cout << partSelection.errorMessage;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
}
//Somewhere we need to store the location we are currently preparing to modify
//We now ask what the user want to with that part
cout << partModification.prompt;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
//Validate to see if the option chosen was a valid one
while (!menuValidation(menuOption, partModification)){
cout << partModification.errorMessage;
cin >> menuOption;
cout << "User entered: " << menuOption << endl;
}
} else {
//If we didn't select one it means we selected 2 and now need to exit our loop;
}
return 0;
}