-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandwich.cpp
48 lines (39 loc) · 1.33 KB
/
sandwich.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
// bruschetta.cpp
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include "halfmeal.h"
#include "sandwich.h"
#include "ingredient.h"
#include "fooddatabase.h"
using std::string;
using std::vector;
using std::pair;
using std::cout;
using std::endl;
Sandwich::Sandwich( const FoodDatabase& fdb, const vector< pair< string, size_t > >& used, const vector< pair< string, size_t > >& haveLeft, size_t freq) : Halfmeal( freq )
{
m_bread = getIngred( "sandwich bread", fdb, used, haveLeft );
m_foodNames.push_back(m_bread.getName());
m_mainfilling = getIngred("sandwich main filling", fdb, used, haveLeft);
m_foodNames.push_back(m_mainfilling.getName());
m_topping1 = getIngred("sandwich topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping1.getName());
m_topping2 = getIngred("sandwich topping", fdb, used, haveLeft);
m_foodNames.push_back(m_topping2.getName());
}
void Sandwich::printHalfmeal() const
{
cout << "Sandwich: " << m_bread << ", " << m_mainfilling;
cout << ", " << m_topping1 << ", " << m_topping2;
cout << endl;
}
double Sandwich::getCost() const
{
double cost = 0;
cost += m_bread.getCost();
cost += m_mainfilling.getCost();
cost += m_topping1.getCost() + m_topping2.getCost();
return cost;
}