-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsalad.cpp
55 lines (44 loc) · 1.49 KB
/
salad.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
50
51
52
53
54
55
// salad.cpp
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include "halfmeal.h"
#include "salad.h"
#include "ingredient.h"
#include "fooddatabase.h"
using std::string;
using std::vector;
using std::pair;
using std::cout;
using std::endl;
Salad::Salad( const FoodDatabase& fdb, const vector< pair< string, size_t > >& used, const vector< pair< string, size_t > >& haveLeft, size_t freq) : Halfmeal( freq )
{
m_green = getIngred("green", fdb, used, haveLeft);
m_foodNames.push_back(m_green.getName());
m_topping1 = getIngred("salad topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping1.getName());
m_topping2 = getIngred("salad topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping2.getName());
m_topping3 = getIngred("salad topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping3.getName());
m_topping4 = getIngred("salad topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping4.getName());
m_dressing = getIngred("salad dressing", fdb, used, haveLeft);
m_foodNames.push_back(m_dressing.getName());
}
void Salad::printHalfmeal() const
{
cout << "Salad: " << m_green << ", " << m_topping1;
cout << ", " << m_topping2 << ", " << m_topping3;
cout << ", " << m_topping4 << ", " << m_dressing;
cout << endl;
}
double Salad::getCost() const
{
double cost = 0;
cost += m_green.getCost();
cost += m_topping1.getCost() + m_topping2.getCost() + m_topping3.getCost();
cost += m_dressing.getCost();
return cost;
}