Fixed default constructors, tested compilability.
This commit is contained in:
parent
c7072f949f
commit
2e42bafae3
7
main.cpp
7
main.cpp
|
@ -11,5 +11,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
Database db("test.db");
|
||||
|
||||
vector<RecipeIngredient> ri;
|
||||
ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c")));
|
||||
|
||||
|
||||
|
||||
Recipe rec("Example", ri, Instruction("Hello world"), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(0, 30), QTime(0, 25), 10.0f);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ UnitOfMeasure::UnitOfMeasure(string name, string plural, string abbreviation){
|
|||
this->abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
UnitOfMeasure::UnitOfMeasure() : UnitOfMeasure::UnitOfMeasure("", "", ""){
|
||||
//Default constructor initializes all fields to empty strings.
|
||||
}
|
||||
|
||||
string UnitOfMeasure::getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,10 @@ using namespace std;
|
|||
class UnitOfMeasure
|
||||
{
|
||||
public:
|
||||
//Full constructor.
|
||||
UnitOfMeasure(string name, string plural, string abbreviation);
|
||||
//Constructor with default values.
|
||||
UnitOfMeasure();
|
||||
|
||||
//Getters
|
||||
string getName();
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
#include "model/recipe/recipe.h"
|
||||
|
||||
Recipe::Recipe(){
|
||||
//Set default values when none are specified.
|
||||
this->Recipe("Unnamed Recipe",
|
||||
vector<RecipeIngredient>(),
|
||||
Instruction(),
|
||||
QImage(),
|
||||
vector<RecipeTag>(),
|
||||
QDate.currentDate(),
|
||||
QTime(1, 0),
|
||||
QTime(0, 30),
|
||||
10.0f);
|
||||
}
|
||||
|
||||
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){
|
||||
setName(name);
|
||||
setIngredients(ingredients);
|
||||
|
@ -25,6 +12,10 @@ Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction in
|
|||
setServings(servings);
|
||||
}
|
||||
|
||||
Recipe::Recipe() : Recipe::Recipe("Unnamed Recipe", vector<RecipeIngredient>(), Instruction(), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(1, 0), QTime(0, 30), 10.0f){
|
||||
//Set default values when none are specified.
|
||||
}
|
||||
|
||||
string Recipe::getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
@ -70,7 +61,7 @@ void Recipe::setIngredients(vector<RecipeIngredient> ingredients){
|
|||
}
|
||||
|
||||
void Recipe::setTags(vector<RecipeTag> tags){
|
||||
this->tags = tags
|
||||
this->tags = tags;
|
||||
}
|
||||
|
||||
void Recipe::addIngredient(RecipeIngredient newIngredient){
|
||||
|
|
|
@ -30,9 +30,10 @@ using namespace std;
|
|||
class Recipe
|
||||
{
|
||||
public:
|
||||
Recipe();
|
||||
//Full constructor
|
||||
Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings);
|
||||
//Constructor with default values.
|
||||
Recipe();
|
||||
|
||||
//Getters
|
||||
string getName();
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include "recipetag.h"
|
||||
|
||||
RecipeTag::RecipeTag(){
|
||||
this->RecipeTag("");
|
||||
RecipeTag::RecipeTag() : RecipeTag(""){
|
||||
//Default constructor sets value to empty string.
|
||||
}
|
||||
|
||||
RecipeTag::RecipeTag(string val){
|
||||
this->value = val;
|
||||
}
|
||||
|
||||
RecipeTag::getValue(){
|
||||
string RecipeTag::getValue(){
|
||||
return this->value;
|
||||
}
|
||||
|
||||
RecipeTag::setValue(string newValue){
|
||||
void RecipeTag::setValue(string newValue){
|
||||
this->value = newValue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue