2018-02-12 13:24:11 +00:00
|
|
|
#include "model/recipe/recipe.h"
|
2018-02-02 12:27:57 +00:00
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
Recipe::Recipe(string name, string author, vector<Ingredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){
|
2018-02-12 18:44:35 +00:00
|
|
|
setName(name);
|
2018-03-31 13:02:35 +00:00
|
|
|
setAuthor(author);
|
2018-02-12 18:44:35 +00:00
|
|
|
setIngredients(ingredients);
|
|
|
|
setInstruction(instruction);
|
|
|
|
setImage(image);
|
|
|
|
setTags(tags);
|
|
|
|
setCreatedDate(createdDate);
|
|
|
|
setPrepTime(prepTime);
|
|
|
|
setCookTime(cookTime);
|
|
|
|
setServings(servings);
|
2018-02-12 13:24:11 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
Recipe::Recipe() : Recipe::Recipe("", "", vector<Ingredient>(), Instruction(), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(), QTime(), 1.0f){
|
2018-02-12 19:27:27 +00:00
|
|
|
//Set default values when none are specified.
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
string Recipe::getName() const{
|
2018-03-31 13:02:35 +00:00
|
|
|
return this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
string Recipe::getAuthor() const{
|
|
|
|
return this->authorName;
|
2018-02-12 13:24:11 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
vector<Ingredient> Recipe::getIngredients() const{
|
2018-03-30 10:29:10 +00:00
|
|
|
return this->ingredients;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
Instruction Recipe::getInstruction() const{
|
2018-02-12 14:15:04 +00:00
|
|
|
return this->instruction;
|
2018-02-02 12:27:57 +00:00
|
|
|
}
|
2018-02-12 18:37:35 +00:00
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
QImage Recipe::getImage() const{
|
2018-03-03 09:18:38 +00:00
|
|
|
return this->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<RecipeTag> Recipe::getTags() const{
|
|
|
|
return this->tags;
|
2018-02-12 18:37:35 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
QDate Recipe::getCreatedDate() const{
|
2018-02-12 18:37:35 +00:00
|
|
|
return this->createdDate;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
QTime Recipe::getPrepTime() const{
|
2018-02-12 18:37:35 +00:00
|
|
|
return this->prepTime;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
QTime Recipe::getCookTime() const{
|
2018-02-12 18:37:35 +00:00
|
|
|
return this->cookTime;
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
QTime Recipe::getTotalTime() const{
|
2018-02-12 18:37:35 +00:00
|
|
|
return QTime(this->cookTime.hour() + this->prepTime.hour(), this->cookTime.minute() + this->prepTime.minute(), this->cookTime.second() + this->prepTime.second());
|
|
|
|
}
|
|
|
|
|
2018-02-13 09:22:05 +00:00
|
|
|
float Recipe::getServings() const{
|
2018-03-29 14:09:58 +00:00
|
|
|
return this->servings;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Recipe::isEmpty() const{
|
|
|
|
return this->name.empty();
|
2018-02-12 18:37:35 +00:00
|
|
|
}
|
2018-02-12 18:44:35 +00:00
|
|
|
|
|
|
|
void Recipe::setName(string newName){
|
2018-03-31 13:02:35 +00:00
|
|
|
this->name = newName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setAuthor(string newName){
|
|
|
|
this->authorName = newName;
|
2018-02-12 18:44:35 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
void Recipe::setIngredients(vector<Ingredient> ingredients){
|
2018-02-12 18:44:35 +00:00
|
|
|
this->ingredients = ingredients;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setTags(vector<RecipeTag> tags){
|
2018-02-12 19:27:27 +00:00
|
|
|
this->tags = tags;
|
2018-02-12 18:44:35 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
void Recipe::addIngredient(Ingredient newIngredient){
|
2018-02-12 18:44:35 +00:00
|
|
|
this->ingredients.push_back(newIngredient);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setInstruction(Instruction newInstruction){
|
|
|
|
this->instruction = newInstruction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setImage(QImage newImage){
|
|
|
|
this->image = newImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setCreatedDate(QDate newDate){
|
|
|
|
this->createdDate = newDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setPrepTime(QTime newTime){
|
|
|
|
this->prepTime = newTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setCookTime(QTime newTime){
|
|
|
|
this->cookTime = newTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::setServings(float newServingsCount){
|
2018-03-03 09:18:38 +00:00
|
|
|
this->servings = newServingsCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Recipe::print(){
|
2018-03-31 13:02:35 +00:00
|
|
|
printf("Recipe: %s, Created on: %s, by %s, Prep time: %s, Cook time: %s, Serves: %f\n",
|
2018-03-03 09:18:38 +00:00
|
|
|
this->name.c_str(),
|
2018-03-31 13:02:35 +00:00
|
|
|
this->authorName.c_str(),
|
2018-03-03 09:18:38 +00:00
|
|
|
this->createdDate.toString().toStdString().c_str(),
|
|
|
|
this->prepTime.toString().toStdString().c_str(),
|
|
|
|
this->cookTime.toString().toStdString().c_str(),
|
|
|
|
this->servings);
|
|
|
|
printf("\tInstruction: %s\n", this->instruction.getHTML().c_str());
|
|
|
|
printf("\tIngredients:\n");
|
2018-05-22 19:24:36 +00:00
|
|
|
for (Ingredient i : this->ingredients){
|
|
|
|
printf("\t\t%s\n", i.getContent().c_str());
|
2018-03-03 09:18:38 +00:00
|
|
|
}
|
|
|
|
printf("\tTags:\n");
|
2018-05-22 19:24:36 +00:00
|
|
|
for (RecipeTag t : this->tags){
|
2018-03-03 09:18:38 +00:00
|
|
|
printf("\t\t%s\n", t.getValue().c_str());
|
|
|
|
}
|
2018-02-12 18:44:35 +00:00
|
|
|
}
|