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