55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
|
#include "menu.hpp"
|
||
|
|
||
|
void LunchRest::Menu::addMeal(bool soup, const std::string &name, const std::string &desc, int price) {
|
||
|
_meals.emplace_back(soup, name, desc, price);
|
||
|
}
|
||
|
|
||
|
void LunchRest::Menu::addMeal(const LunchRest::Meal &meal) {
|
||
|
_meals.push_back(meal);
|
||
|
}
|
||
|
|
||
|
bool LunchRest::Menu::hasSoup() const {
|
||
|
bool ret = false;
|
||
|
for(auto &x : _meals) {
|
||
|
ret |= x.isSoup();
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
LunchRest::Meal LunchRest::Menu::getSoup() const {
|
||
|
for(auto &x : _meals) {
|
||
|
if(x.isSoup())
|
||
|
return x;
|
||
|
}
|
||
|
return Meal(true, "", "", 0);
|
||
|
}
|
||
|
|
||
|
std::vector<LunchRest::Meal> LunchRest::Menu::getNonSoupMeals() {
|
||
|
std::vector<Meal> ret{};
|
||
|
for(auto &x : _meals) {
|
||
|
if(!x.isSoup())
|
||
|
ret.push_back(x);
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
const std::vector<LunchRest::Meal> &LunchRest::Menu::getMeals() const {
|
||
|
return _meals;
|
||
|
}
|
||
|
|
||
|
unsigned long int LunchRest::Menu::getSoupIndex() const {
|
||
|
for(unsigned long int i = 0; i < _meals.size(); i++) {
|
||
|
if(_meals[i].isSoup())
|
||
|
return i;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
void LunchRest::Menu::setInvalidMenu() {
|
||
|
_valid = false;
|
||
|
}
|
||
|
|
||
|
bool LunchRest::Menu::isValid() const {
|
||
|
return _valid;
|
||
|
}
|