-
Notifications
You must be signed in to change notification settings - Fork 0
/
alacarte.cpp
49 lines (39 loc) · 1.38 KB
/
alacarte.cpp
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
// alacarte.cpp
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include "meal.h"
#include "alacarte.h"
#include "ingredient.h"
#include "fooddatabase.h"
using std::string;
using std::vector;
using std::pair;
using std::cout;
using std::endl;
typedef vector< pair< string,size_t> >::const_iterator vpiter;
typedef vector<string>::const_iterator vsiter;
Alacarte::Alacarte( const FoodDatabase& fdb, const vector< pair< string, size_t > >& used, const vector< pair< string, size_t > >& haveLeft, size_t ID, size_t freq) : Meal( ID, freq )
{
m_veg = getIngred("vegetable", fdb, used, haveLeft);
m_foodInMeal.push_back(m_veg.getName());
m_protein = getIngred("protein", fdb, used, haveLeft);
m_foodInMeal.push_back(m_protein.getName());
m_starch = getIngred("starch", fdb, used, haveLeft);
m_foodInMeal.push_back(m_starch.getName());
m_savory = getIngred("savory", fdb, used, haveLeft);
m_foodInMeal.push_back(m_savory.getName());
}
void Alacarte::printMeal() const
{
cout << "Meal " << m_ID << endl;
cout << "\tFrequency: " << m_freq << endl;
cout << "\tA La Carte: " << m_veg.getName() << ", " << m_starch.getName();
cout << ", " << m_protein.getName() << ", " << m_savory.getName() << endl << endl;
}
double Alacarte::getMealCost() const
{
double cost = m_veg.getCost() + m_protein.getCost() + m_starch.getCost() + m_savory.getCost();
return cost;
}