Added getTotalTime() derived getter method.
This commit is contained in:
parent
c928533e6a
commit
7d358d6e55
|
@ -6,19 +6,14 @@ Recipe::Recipe(){
|
|||
vector<RecipeIngredient>(),
|
||||
Instruction(),
|
||||
QImage(),
|
||||
vector<string>())
|
||||
this->name = "Unnamed Recipe";
|
||||
this->ingredients = vector<RecipeIngredient>();
|
||||
this->instruction = Instruction();
|
||||
this->image = QImage();
|
||||
this->tags = vector<string>();
|
||||
this->createdDate = QDate.currentDate();
|
||||
this->prepTime = QTime(1, 0);
|
||||
this->cookTime = QTime(0, 30);
|
||||
this->servings = 10;
|
||||
vector<RecipeTag>(),
|
||||
QDate.currentDate(),
|
||||
QTime(1, 0),
|
||||
QTime(0, 30),
|
||||
10.0f);
|
||||
}
|
||||
|
||||
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<string> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){
|
||||
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> 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<RecipeIngredient> ingredients, Instruction in
|
|||
this->servings = servings;
|
||||
}
|
||||
|
||||
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction)
|
||||
{
|
||||
this->name = name;
|
||||
this->ingredients = ingredients;
|
||||
this->instruction = instruction;
|
||||
}
|
||||
|
||||
string Recipe::getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
@ -48,3 +36,27 @@ vector<RecipeIngredient> 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;
|
||||
}
|
||||
|
|
|
@ -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<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<string> tags);
|
||||
Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings);
|
||||
|
||||
//Getters
|
||||
string getName();
|
||||
vector<RecipeIngredient> getIngredients();
|
||||
Instruction getInstruction();
|
||||
QImage getImage();
|
||||
vector<string> getTags();
|
||||
vector<RecipeTag> 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<string> tags; //The list of tags which can be used to categorize the recipe.
|
||||
vector<RecipeTag> 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.
|
||||
|
|
Loading…
Reference in New Issue