-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStation.cpp
More file actions
55 lines (51 loc) · 1.34 KB
/
Copy pathStation.cpp
File metadata and controls
55 lines (51 loc) · 1.34 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
#include <iostream>
#include <iomanip>
#include <string>
#include "Station.h"
#include "Utilities.h"
namespace sdds
{
size_t Station::m_widthField = 0;
size_t Station::id_generator = 0;
Station::Station(const std::string& station)
{
Utilities ut;
bool more = false;
size_t position = 0;
m_id = ++id_generator;
m_name = ut.extractToken(station, position, more);
m_serialNum = stoi(ut.extractToken(station, position, more));
m_stockNum = stoi(ut.extractToken(station, position, more));
(m_widthField < ut.getFieldWidth()) ? m_widthField = ut.getFieldWidth() : 1;
m_desc = ut.extractToken(station, position, more);
}
const std::string& Station::getItemName() const
{
return m_name;
}
size_t Station::getNextSerialNumber()
{
return m_serialNum++;
}
size_t Station::getQuantity() const
{
return m_stockNum;
}
void Station::updateQuantity()
{
if (m_stockNum > 0)
m_stockNum--;
}
void Station::display(std::ostream& os, bool full) const
{
os << std::setw(3) << std::setfill('0') << std::right << m_id << " | ";
os << std::setw(m_widthField + 1) << std::setfill(' ') << std::left << m_name << " | ";
os << std::setw(6) << std::setfill('0') << std::right << m_serialNum << " | ";
if (full)
{
os << std::setfill(' ') << std::right << std::setw(4) << m_stockNum << " | ";
os << m_desc;
}
os << std::endl;
}
}