diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp index 149b3cd..e468fbc 100644 --- a/model/recipe/recipe.cpp +++ b/model/recipe/recipe.cpp @@ -6,19 +6,14 @@ Recipe::Recipe(){ vector(), Instruction(), QImage(), - vector()) - this->name = "Unnamed Recipe"; - this->ingredients = vector(); - this->instruction = Instruction(); - this->image = QImage(); - this->tags = vector(); - this->createdDate = QDate.currentDate(); - this->prepTime = QTime(1, 0); - this->cookTime = QTime(0, 30); - this->servings = 10; + vector(), + QDate.currentDate(), + QTime(1, 0), + QTime(0, 30), + 10.0f); } -Recipe::Recipe(string name, vector ingredients, Instruction instruction, QImage image, vector tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){ +Recipe::Recipe(string name, vector ingredients, Instruction instruction, QImage image, vector tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){ this->name = name; this->ingredients = ingredients; this->instruction = instruction; @@ -30,13 +25,6 @@ Recipe::Recipe(string name, vector ingredients, Instruction in this->servings = servings; } -Recipe::Recipe(string name, vector ingredients, Instruction instruction) -{ - this->name = name; - this->ingredients = ingredients; - this->instruction = instruction; -} - string Recipe::getName(){ return this->name; } @@ -48,3 +36,27 @@ vector Recipe::getIngredients(){ Instruction Recipe::getInstruction(){ return this->instruction; } + +QImage Recipe::getImage(){ + return this->image; +} + +QDate Recipe::getCreatedDate(){ + return this->createdDate; +} + +QTime Recipe::getPrepTime(){ + return this->prepTime; +} + +QTime Recipe::getCookTime(){ + return this->cookTime; +} + +QTime Recipe::getTotalTime(){ + return QTime(this->cookTime.hour() + this->prepTime.hour(), this->cookTime.minute() + this->prepTime.minute(), this->cookTime.second() + this->prepTime.second()); +} + +float Recipe::getServings(){ + return this->servings; +} diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h index 9600bd0..726e5a4 100644 --- a/model/recipe/recipe.h +++ b/model/recipe/recipe.h @@ -9,6 +9,7 @@ #include "model/recipe/ingredients/recipeingredient.h" #include "model/recipe/instruction.h" +#include "model/recipe/tags/recipetag.h" using namespace std; @@ -31,23 +32,29 @@ class Recipe public: Recipe(); //Full constructor - Recipe(string name, vector ingredients, Instruction instruction, QImage image, vector tags); + Recipe(string name, vector ingredients, Instruction instruction, QImage image, vector tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings); //Getters string getName(); vector getIngredients(); Instruction getInstruction(); QImage getImage(); - vector getTags(); + vector getTags(); QDate getCreatedDate(); QTime getPrepTime(); QTime getCookTime(); - QTime getTotalTime(); + QTime getTotalTime(); //Derived method to add prep and cook times. float getServings(); + //Setters void setName(string newName); void addIngredient(RecipeIngredient newIngredient); void setInstruction(Instruction newInstruction); + void setImage(QImage newImage); + void setCreatedDate(QDate newDate); + void setPrepTime(QTime newTime); + void setCookTime(QTime newTime); + void setServings(float newServingsCount); private: //Main information. string name; //The name of the recipe. @@ -55,7 +62,7 @@ private: Instruction instruction; //The instruction HTML document. QImage image; //An image displayed alongside the recipe. //Auxiliary Information. - vector tags; //The list of tags which can be used to categorize the recipe. + vector tags; //The list of tags which can be used to categorize the recipe. QDate createdDate; //The date the recipe was created. QTime prepTime; //The time taken for preparation. QTime cookTime; //The time taken to cook.