-
Notifications
You must be signed in to change notification settings - Fork 0
/
Waitress.h
45 lines (39 loc) · 952 Bytes
/
Waitress.h
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
#ifndef WAITRESS_H
#define WAITRESS_H
#include "Menu.h"
#include "Iterator.h"
#include <iostream>
#include <memory>
class Waitress {
public:
Waitress(Menu *phm, Menu *dm) :
pancakeHouseMenu(phm), dinerMenu(dm) {}
void printMenu();
void printMenu(Iterator<MenuItem> *iteator) const;
private:
Menu *pancakeHouseMenu;
Menu *dinerMenu;
};
inline
void
Waitress::printMenu()
{
auto pancakeIterator = pancakeHouseMenu->createIterator();
auto dinerIterator = dinerMenu->createIterator();
std::cout << "MENU\n----\nBREAKFAST\n";
printMenu(pancakeIterator.get());
std::cout << "\nLUNCH\n";
printMenu(dinerIterator.get());
}
inline
void
Waitress::printMenu(Iterator<MenuItem> *iteator) const
{
while (iteator->hasNext()) {
auto menuItem = iteator->next();
std::cout << menuItem->getName() << ", ";
std::cout << menuItem->getPrice() << " -- ";
std::cout << menuItem->getDescription() << '\n';
}
}
#endif /* WAITRESS_H */