-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.cpp
33 lines (27 loc) · 1.04 KB
/
container.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
#include "container.h"
namespace Mice {
Container::Container(std::string name, std::string description, double cost, double price,
int max_scoops)
: Item(name, description, cost, price), _max_scoops{max_scoops} { }
Container::Container(std::istream& ist) {
// The header must have been stripped from the incoming stream at this point
getline(ist, _name);
ist >> _cost; ist.ignore();
ist >> _price; ist.ignore();
ist >> _quantity; ist.ignore();
ist >> _max_scoops; ist.ignore();
getline(ist, _description);
}
void Container::save(std::ostream& ost) {
ost << "#" << std::endl << "CONTAINER" << std::endl; // header
ost << _name << std::endl;
ost << _cost << std::endl;
ost << _price << std::endl;
ost << _quantity << std::endl;
ost << _max_scoops << std::endl;
ost << _description << std::endl;
}
std::string Container::type() const {return "Container";}
int Container::max_scoops() const {return _max_scoops;}
void Container::set_photo(std::string photo) {_photo = photo;}
}