-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.cpp
More file actions
61 lines (46 loc) · 1.23 KB
/
Copy pathItem.cpp
File metadata and controls
61 lines (46 loc) · 1.23 KB
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
56
57
58
59
60
61
//Author Name: Victor A.
#include <iostream>
#include <string>
#include "Item.h"
namespace std
{
size_t Item::m_widthField = 0;
Item::Item(const std::string line)
{
Utilities utilities;
bool more = true;
size_t next = 0u;
m_name = utilities.extractToken(line, next, more);
m_serialNumber = std::stoi(utilities.extractToken(line, next, more));
m_quantity = std::stoi(utilities.extractToken(line, next, more));
m_widthField = utilities.getFieldWidth();
m_description = utilities.extractToken(line, next, more);
}
const std::string& Item::getName() const
{
return m_name;
}
const unsigned int Item::getSerialNumber()
{
return m_serialNumber++;
}
const unsigned int Item::getQuantity()
{
return m_quantity;
}
void Item::updateQuantity() {
if (m_quantity >= 0) {
m_quantity--;
}
}
void Item::display(std::ostream& os, bool full) const {
os << std::setfill(' ') << std::setw(m_widthField) << std::left << m_name << " [";
os << std::setfill('0') << std::setw(6) << std::left << m_serialNumber << "] ";
if (full == true)
{
os << std::setfill(' ') << "Quantity: " << std::setw(m_widthField) << std::left << m_quantity;
os << " Description: " << m_description;
}
os << std::endl;
}
}