2018-02-12 14:15:04 +00:00
|
|
|
#include "model/recipe/ingredients/recipeingredient.h"
|
2018-02-02 12:27:57 +00:00
|
|
|
|
2018-03-10 07:51:17 +00:00
|
|
|
RecipeIngredient::RecipeIngredient(string name, string foodGroup, float quantity, UnitOfMeasure unit, string comment) : Ingredient(name, foodGroup){
|
2018-02-02 12:27:57 +00:00
|
|
|
setQuantity(quantity);
|
|
|
|
setUnit(unit);
|
2018-03-10 07:51:17 +00:00
|
|
|
setComment(comment);
|
2018-02-02 12:27:57 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 07:51:17 +00:00
|
|
|
RecipeIngredient::RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit, string comment){
|
2018-02-02 12:27:57 +00:00
|
|
|
setName(i.getName());
|
|
|
|
setFoodGroup(i.getFoodGroup());
|
|
|
|
setQuantity(quantity);
|
2018-03-03 09:18:38 +00:00
|
|
|
setUnit(unit);
|
2018-03-10 07:51:17 +00:00
|
|
|
setComment(comment);
|
2018-03-03 09:18:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RecipeIngredient::RecipeIngredient(){
|
|
|
|
|
2018-02-02 12:27:57 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
float RecipeIngredient::getQuantity() const{
|
2018-02-12 18:48:22 +00:00
|
|
|
return this->quantity;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
UnitOfMeasure RecipeIngredient::getUnit() const{
|
2018-02-12 18:48:22 +00:00
|
|
|
return this->unit;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
string RecipeIngredient::getComment() const{
|
2018-02-02 12:27:57 +00:00
|
|
|
return this->comment;
|
|
|
|
}
|
|
|
|
|
2018-02-12 18:48:22 +00:00
|
|
|
void RecipeIngredient::setQuantity(float newQuantity){
|
2018-02-02 12:27:57 +00:00
|
|
|
this->quantity = newQuantity;
|
|
|
|
}
|
|
|
|
|
2018-02-12 18:20:38 +00:00
|
|
|
void RecipeIngredient::setUnit(UnitOfMeasure newUnit){
|
2018-02-02 12:27:57 +00:00
|
|
|
this->unit = newUnit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RecipeIngredient::setComment(string newComment){
|
2018-03-11 07:57:57 +00:00
|
|
|
this->comment = newComment;
|
|
|
|
}
|
|
|
|
|
|
|
|
string RecipeIngredient::toString(){
|
|
|
|
string result;
|
|
|
|
if (std::ceil(this->getQuantity()) == this->getQuantity()){
|
|
|
|
result += std::to_string((int)this->getQuantity());
|
|
|
|
} else {
|
|
|
|
result += StringUtils::toString(this->getQuantity());
|
|
|
|
}
|
|
|
|
result += " " + this->getUnit().getAbbreviation() + " " + this->getName();
|
|
|
|
if (!this->getComment().empty()) result += " ~" + this->getComment();
|
|
|
|
|
|
|
|
return result;
|
2018-02-02 12:27:57 +00:00
|
|
|
}
|