1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include<string>
#include<vector>
using namespace std;
enum Measurement{ cup = 1, tablespoons = 2, each = 3 };
// Index this by Measurement to get the name of a measurement
const char* meas_names[] =
{ "" // zero not used
"cup",
"tablespoon",
"each"
};
struct Ingredient
{
float quantity;
Measurement type;
string ingredient;
};
struct Recipe
{
vector <Ingredient> ingredientsList;
vector <string> stepBysteInstructions;
void AddIngredient(const string& ing, float qty, Measurement meas);
};
void Recipe::AddIngredient(const string& ing, float qty, Measurement meas)
{
Ingredient temp;
temp.ingredient = ing;
temp.quantity = qty;
temp.type = meas;
ingredientsList.push_back(temp);
}
int main()
{
Recipe applePie;
applePie.AddIngredient("Unsalted Butter", 0.5, cup);
applePie.AddIngredient("All-Purpose Flour", 2, cup);
applePie.AddIngredient("Cup of Water", 1, cup);
applePie.AddIngredient("Cup of White Sugar", 1, cup);
applePie.AddIngredient("Cup of Packed Brown Sugar", 1, cup);
applePie.AddIngredient("Branny Smith Apples - Peeled, Cored and Sliced", 6, each);
}
|