diff --git a/.gitignore b/.gitignore index b38eccc..b165559 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pro -*.pro.user \ No newline at end of file +*.pro.user +*.autosave \ No newline at end of file diff --git a/model/recipe/ingredients/recipeingredient.cpp b/model/recipe/ingredients/recipeingredient.cpp index d697293..c7d3898 100644 --- a/model/recipe/ingredients/recipeingredient.cpp +++ b/model/recipe/ingredients/recipeingredient.cpp @@ -1,11 +1,11 @@ #include "model/recipe/ingredients/recipeingredient.h" -RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit) : Ingredient(id, name, foodGroup){ +RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, UnitOfMeasure unit) : Ingredient(id, name, foodGroup){ setQuantity(quantity); setUnit(unit); } -RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, string unit){ +RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, UnitOfMeasure unit){ setId(i.getId()); setName(i.getName()); setFoodGroup(i.getFoodGroup()); @@ -21,7 +21,7 @@ void RecipeIngredient::setQuantity(int newQuantity){ this->quantity = newQuantity; } -void RecipeIngredient::setUnit(string newUnit){ +void RecipeIngredient::setUnit(UnitOfMeasure newUnit){ this->unit = newUnit; } diff --git a/model/recipe/ingredients/recipeingredient.h b/model/recipe/ingredients/recipeingredient.h index 486b5a5..8a75c0e 100644 --- a/model/recipe/ingredients/recipeingredient.h +++ b/model/recipe/ingredients/recipeingredient.h @@ -4,6 +4,7 @@ #include #include "model/recipe/ingredients/ingredient.h" +#include "model/recipe/ingredients/unitofmeasure.h" using namespace std; @@ -14,19 +15,19 @@ using namespace std; class RecipeIngredient : public Ingredient { public: - RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit); - RecipeIngredient(Ingredient i, int quantity, string unit); + RecipeIngredient(int id, string name, string foodGroup, int quantity, UnitOfMeasure unit); + RecipeIngredient(Ingredient i, int quantity, UnitOfMeasure unit); int getQuantity(); - string getUnit(); + UnitOfMeasure getUnit(); string getComment(); void setQuantity(int newQuantity); - void setUnit(string newUnit); + void setUnit(UnitOfMeasure newUnit); void setComment(string newComment); private: int quantity; - string unit; + UnitOfMeasure unit; string comment; }; diff --git a/model/recipe/ingredients/unitofmeasure.cpp b/model/recipe/ingredients/unitofmeasure.cpp index 4f5fafe..16d82ef 100644 --- a/model/recipe/ingredients/unitofmeasure.cpp +++ b/model/recipe/ingredients/unitofmeasure.cpp @@ -1,6 +1,19 @@ #include "unitofmeasure.h" -UnitOfMeasure::UnitOfMeasure() -{ - +UnitOfMeasure::UnitOfMeasure(string name, string plural, string abbreviation){ + this->name = name; + this->plural = plural; + this->abbreviation = abbreviation; +} + +string UnitOfMeasure::getName(){ + return this->name; +} + +string UnitOfMeasure::getNamePlural(){ + return this->plural; +} + +string UnitOfMeasure::getAbbreviation(){ + return this->abbreviation; } diff --git a/model/recipe/ingredients/unitofmeasure.h b/model/recipe/ingredients/unitofmeasure.h index 89bc010..62c633d 100644 --- a/model/recipe/ingredients/unitofmeasure.h +++ b/model/recipe/ingredients/unitofmeasure.h @@ -12,12 +12,16 @@ using namespace std; class UnitOfMeasure { public: - UnitOfMeasure(); + UnitOfMeasure(string name, string plural, string abbreviation); + + //Getters + string getName(); + string getNamePlural(); + string getAbbreviation(); private: string name; //The name of the unit of measure. string plural; //The plural name. string abbreviation; //A short version of the unit. - float siBaseUnitEquivalent; //The ratio when compared to the base SI unit for this unit. For example: 1 cup = 237mL. }; #endif // UNITOFMEASURE_H diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp index 2b73e5d..bd61d8d 100644 --- a/model/recipe/recipe.cpp +++ b/model/recipe/recipe.cpp @@ -1,9 +1,28 @@ #include "model/recipe/recipe.h" Recipe::Recipe(){ - this->name = "NULL"; + //Set default values when none are specified. + 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; +} + +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; } Recipe::Recipe(string name, vector ingredients, Instruction instruction) diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h index 47b8e32..9600bd0 100644 --- a/model/recipe/recipe.h +++ b/model/recipe/recipe.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "model/recipe/ingredients/recipeingredient.h" #include "model/recipe/instruction.h" @@ -27,17 +30,36 @@ class Recipe { public: Recipe(); - Recipe(string name, vector ingredients, Instruction instruction); + //Full constructor + Recipe(string name, vector ingredients, Instruction instruction, QImage image, vector tags); + //Getters string getName(); vector getIngredients(); Instruction getInstruction(); + QImage getImage(); + vector getTags(); + QDate getCreatedDate(); + QTime getPrepTime(); + QTime getCookTime(); + QTime getTotalTime(); + float getServings(); + //Setters + void setName(string newName); + void addIngredient(RecipeIngredient newIngredient); + void setInstruction(Instruction newInstruction); private: - string name; - vector tags; - vector ingredients; - Instruction instruction; - + //Main information. + string name; //The name of the recipe. + vector ingredients; //The list of ingredients in the recipe. + 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. + QDate createdDate; //The date the recipe was created. + QTime prepTime; //The time taken for preparation. + QTime cookTime; //The time taken to cook. + float servings; //The number of servings which this recipe produces. }; #endif // RECIPE_H