From cd3f5277853e1f5b26e2da010496ce358cf8e029 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Mon, 12 Feb 2018 19:44:35 +0100 Subject: [PATCH] Created getters/setters for Recipe Class and cleaned up constructor. --- model/recipe/recipe.cpp | 58 ++++++++++++++++++++++++++++++++++------- model/recipe/recipe.h | 2 ++ 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp index e468fbc..2492254 100644 --- a/model/recipe/recipe.cpp +++ b/model/recipe/recipe.cpp @@ -14,15 +14,15 @@ Recipe::Recipe(){ } 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; - this->image = image; - this->tags = tags; - this->createdDate = createdDate; - this->prepTime = prepTime; - this->cookTime = cookTime; - this->servings = servings; + setName(name); + setIngredients(ingredients); + setInstruction(instruction); + setImage(image); + setTags(tags); + setCreatedDate(createdDate); + setPrepTime(prepTime); + setCookTime(cookTime); + setServings(servings); } string Recipe::getName(){ @@ -60,3 +60,43 @@ QTime Recipe::getTotalTime(){ float Recipe::getServings(){ return this->servings; } + +void Recipe::setName(string newName){ + this->name = newName; +} + +void Recipe::setIngredients(vector ingredients){ + this->ingredients = ingredients; +} + +void Recipe::setTags(vector tags){ + this->tags = tags +} + +void Recipe::addIngredient(RecipeIngredient newIngredient){ + 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){ + this->servings = newServingsCount; +} diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h index 726e5a4..df24614 100644 --- a/model/recipe/recipe.h +++ b/model/recipe/recipe.h @@ -48,6 +48,8 @@ public: //Setters void setName(string newName); + void setIngredients(vector ingredients); + void setTags(vector tags); void addIngredient(RecipeIngredient newIngredient); void setInstruction(Instruction newInstruction); void setImage(QImage newImage);