-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuItem.h
More file actions
36 lines (32 loc) · 924 Bytes
/
MenuItem.h
File metadata and controls
36 lines (32 loc) · 924 Bytes
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
#ifndef MENU_ITEM_H
#define MENU_ITEM_H
#include "MenuComponent.h"
#include <string>
#include <iostream>
#include <string_view>
class MenuItem : public MenuComponent {
public:
MenuItem(std::string_view n, std::string_view d, bool v, double p)
: name(n), description(d), vegetarian(v), price(p) { }
std::string getName() const override { return name; }
std::string getDescription() const override { return description; }
bool isVegetarian() const override { return vegetarian; }
double getPrice() const override { return price; }
void print() const override;
private:
std::string name;
std::string description;
bool vegetarian = false;
double price = 0.0;
};
inline
void
MenuItem::print() const
{
std::cout << " " << getName();
if (isVegetarian())
std::cout << "(v)";
std::cout << ", " << getPrice() << '\n';
std::cout << " --" << getDescription() << '\n';
}
#endif /* MENU_ITEM_H */