-
Notifications
You must be signed in to change notification settings - Fork 0
/
Station.cpp
79 lines (69 loc) · 1.29 KB
/
Station.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// OOP345 Workshop 2
// File Station.cpp
// Version 1.0
// Date 28th May, 2017
// Author Bolarinwa Komolafe, Email:bkomolafe@myseneca.ca, Student ID:122948169
// Description
// This file contains the definition for the functions in Station class
#include "Station.h"
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
namespace w2 {
Station::Station()
{
m_stationName = "Yet to be specified";
m_noOfAdultPasses = 0;
m_noOfStudentPass = 0;
}
void Station::set(const std::string & name, unsigned studentPass, unsigned adultPass)
{
m_stationName = name;
m_noOfStudentPass = studentPass;
m_noOfAdultPasses = adultPass;
}
void Station::update(PassType pass, int no)
{
unsigned int change;
if (pass == STUDENT)
{
if (no < 0)
{
change = abs(no);
m_noOfStudentPass -= change;
}
else
m_noOfStudentPass += no;
}
else
{
if (no < 0)
{
change = abs(no);
m_noOfAdultPasses -= change;
}
else
m_noOfAdultPasses += no;
}
}
unsigned Station::inStock(PassType pass)
{
unsigned int output;
if (pass == STUDENT)
{
output = this->m_noOfStudentPass;
}
else
{
output = this->m_noOfAdultPasses;
}
return output;
}
const std::string & Station::getName()
{
// TODO: insert return statement here
return this->m_stationName;
}
}