|
|
@ -14,15 +14,16 @@ void InputManager::setSelectedOption(MenuOption option) { |
|
|
|
this->selectedOption = option; |
|
|
|
} |
|
|
|
|
|
|
|
InputManager::MenuOption InputManager::askMenuOption(std::string question, std::vector<std::string> answers) { |
|
|
|
InputManager::MenuOption InputManager::askMenuOption(const std::string& question, const std::vector<std::string>& answers) { |
|
|
|
this->displayDialog(question, answers); |
|
|
|
|
|
|
|
int input; |
|
|
|
std::cin >> input; |
|
|
|
|
|
|
|
return input; |
|
|
|
} |
|
|
|
|
|
|
|
void InputManager::displayDialog(std::string question, std::vector<std::string> answers) { |
|
|
|
void InputManager::displayDialog(const std::string& question, const std::vector<std::string>& answers) { |
|
|
|
std::cout << question << std::endl; |
|
|
|
std::cout << "-------------------------------" << std::endl; |
|
|
|
int counter = 0; |
|
|
@ -34,16 +35,11 @@ void InputManager::displayDialog(std::string question, std::vector<std::string> |
|
|
|
} |
|
|
|
|
|
|
|
InputManager::WareAndAmount InputManager::displayAddWareDialog() { |
|
|
|
std::string name; |
|
|
|
bool hasCooling; |
|
|
|
double width, height; |
|
|
|
int amount; |
|
|
|
|
|
|
|
name = getInput<std::string>("Enter Ware Name:"); |
|
|
|
hasCooling = getNeedsCooling(); |
|
|
|
width = getInput<double>("Enter Ware width:"); |
|
|
|
height = getInput<double>("Enter Ware height:"); |
|
|
|
amount = getInput<int>("Enter Ware amount:"); |
|
|
|
std::string name = getInput<std::string>("Enter Ware Name:"); |
|
|
|
bool hasCooling = getNeedsCooling(); |
|
|
|
double width = getInput<double>("Enter Ware width:"); |
|
|
|
double height = getInput<double>("Enter Ware height:"); |
|
|
|
int amount = getInput<int>("Enter Ware amount:"); |
|
|
|
|
|
|
|
InputManager::WareAndAmount wareAndAmount; |
|
|
|
wareAndAmount.ware = Ware(name, hasCooling, width, height); |
|
|
@ -53,11 +49,8 @@ InputManager::WareAndAmount InputManager::displayAddWareDialog() { |
|
|
|
} |
|
|
|
|
|
|
|
InputManager::WareAndAmount InputManager::displayRemoveWareDialog() { |
|
|
|
std::string name; |
|
|
|
int amount; |
|
|
|
|
|
|
|
name = getInput<std::string>("Enter Name of the Ware you want to remove:"); |
|
|
|
amount = getInput<int>("Enter amount you want to remove:"); |
|
|
|
std::string name = getInput<std::string>("Enter Name of the Ware you want to remove:"); |
|
|
|
int amount = getInput<int>("Enter amount you want to remove:"); |
|
|
|
|
|
|
|
InputManager::WareAndAmount wareAndAmount; |
|
|
|
|
|
|
@ -100,7 +93,7 @@ void InputManager::displayMainMenu() { |
|
|
|
break; |
|
|
|
} |
|
|
|
case 3: { |
|
|
|
std::vector<Ware> waren = this->editor->getWarenStorage().getAllWaren(); |
|
|
|
std::vector<Ware> waren = this->editor->getWarenStorage()->getAllWaren(); |
|
|
|
displayWaren(waren); |
|
|
|
break; |
|
|
|
} |
|
|
@ -108,13 +101,17 @@ void InputManager::displayMainMenu() { |
|
|
|
return; |
|
|
|
break; |
|
|
|
} |
|
|
|
default: { |
|
|
|
return; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
displayMainMenu(); |
|
|
|
} |
|
|
|
|
|
|
|
// if no more initialization needed --> refactor to setStorageEditor
|
|
|
|
void InputManager::displayWaren(const std::vector<Ware> waren) { |
|
|
|
void InputManager::displayWaren(const std::vector<Ware>& waren) { |
|
|
|
std::cout << "Liste der sich im Lager befindlichen Waren:" << std::endl; |
|
|
|
std::vector<InputManager::WareAndAmount> sortedWarenList = sortAndGroupWaren(waren); |
|
|
|
|
|
|
@ -222,7 +219,7 @@ std::vector<InputManager::WareAndAmount> InputManager::sortAndGroupWaren(const s |
|
|
|
|
|
|
|
bool InputManager::getNeedsCooling() { |
|
|
|
std::string input; |
|
|
|
bool hasCooling; |
|
|
|
bool hasCooling = false; |
|
|
|
|
|
|
|
std::cout << "Does Ware need Cooling? (y/n)" << std::endl; |
|
|
|
try { |
|
|
@ -247,7 +244,7 @@ bool InputManager::getNeedsCooling() { |
|
|
|
|
|
|
|
//std::istream
|
|
|
|
template <typename T> |
|
|
|
T InputManager::getInput(std::string message) const { |
|
|
|
T InputManager::getInput(const std::string& message) const { |
|
|
|
std::cout << message << std::endl; |
|
|
|
T val; |
|
|
|
try { |
|
|
|