Cleaned up getters/setters for RecipeIngredient.

This commit is contained in:
Andrew Lalis 2018-02-12 19:48:22 +01:00
parent cd3f527785
commit b6093aeee9
2 changed files with 20 additions and 8 deletions

View File

@ -1,11 +1,11 @@
#include "model/recipe/ingredients/recipeingredient.h"
RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, UnitOfMeasure unit) : Ingredient(id, name, foodGroup){
RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, float quantity, UnitOfMeasure unit) : Ingredient(id, name, foodGroup){
setQuantity(quantity);
setUnit(unit);
}
RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, UnitOfMeasure unit){
RecipeIngredient::RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit){
setId(i.getId());
setName(i.getName());
setFoodGroup(i.getFoodGroup());
@ -13,11 +13,19 @@ RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, UnitOfMeasure uni
setUnit(unit);
}
float RecipeIngredient::getQuantity(){
return this->quantity;
}
UnitOfMeasure RecipeIngredient::getUnit(){
return this->unit;
}
string RecipeIngredient::getComment(){
return this->comment;
}
void RecipeIngredient::setQuantity(int newQuantity){
void RecipeIngredient::setQuantity(float newQuantity){
this->quantity = newQuantity;
}

View File

@ -15,18 +15,22 @@ using namespace std;
class RecipeIngredient : public Ingredient
{
public:
RecipeIngredient(int id, string name, string foodGroup, int quantity, UnitOfMeasure unit);
RecipeIngredient(Ingredient i, int quantity, UnitOfMeasure unit);
//Constructor for new RecipeIngredient without starting child ingredient.
RecipeIngredient(int id, string name, string foodGroup, float quantity, UnitOfMeasure unit);
//Constructor using data from a child ingredient.
RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit);
int getQuantity();
//Getters
float getQuantity();
UnitOfMeasure getUnit();
string getComment();
void setQuantity(int newQuantity);
//Setters
void setQuantity(float newQuantity);
void setUnit(UnitOfMeasure newUnit);
void setComment(string newComment);
private:
int quantity;
float quantity;
UnitOfMeasure unit;
string comment;
};