-
Notifications
You must be signed in to change notification settings - Fork 1
/
tallySheet.h
153 lines (131 loc) · 6.03 KB
/
tallySheet.h
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/******************************************************************************/
/**************************** TALLY SHEET CLASS *******************************/
/******************************************************************************/
/*
Notes:
-
*/
#include <iostream>
using namespace std;
/******************************************************************************/
/***************************** CLASS STRUCTURE ********************************/
/******************************************************************************/
class TallySheet{
private:
unsigned int _cakes_ordered; // Number of cakes ordered
unsigned int _croissants_ordered; // Number of croissants ordered
unsigned int _cakes_delivered; // Number of cakes delivered
unsigned int _croissants_delivered; // Number of croissants delivered
unsigned int _cakes_produced; // Number of cakes produced
unsigned int _croissants_produced; // Number of croissants produced
unsigned int _cakes_sold; // Number of cakes sold
unsigned int _croissants_sold; // Number of croissants sold
unsigned int _cakes_discarded; // Number of cakes discarded
unsigned int _croissants_discarded; // Number of croissants discarded
unsigned int _cakes_missed; // Number of cakes missed
unsigned int _croissants_missed; // Number of croissants missed
private:
// Ctor
TallySheet(); // tallysheet Ctor
// Operational Functions
void Ordered(int food_type); // Increment appropriate order tally
void Delivered(int food_type); // Increment appropriate delivery tally
void Produced(int food_type); // Increment appropriate produced tally
void Sold(int food_type); // Increment appropriate sold tally
void Discarded(int food_type); // Increment appropriate discarded tally
void Missed(int food_type); // Increment appropriate missed tally
// Misc
void Reset(void); // Reset all tally counters
//Writer Functions
void WriteReport(ostream &out); // write Daily report to out
};
/******************************************************************************/
/********************************** CTOR **************************************/
/******************************************************************************/
TallySheet::TallySheet() // tallysheet Ctor
{
_cakes_ordered = 0;
_croissants_ordered = 0;
_cakes_delivered = 0;
_croissants_delivered = 0;
_cakes_produced = 0;
_croissants_produced = 0;
_cakes_sold = 0;
_croissants_sold = 0;
_cakes_discarded = 0;
_croissants_discarded = 0;
_cakes_missed = 0;
_croissants_missed = 0;
}
/******************************************************************************/
/************************** OPERATIONAL FUNCTIONS *****************************/
/******************************************************************************/
void TallySheet::Ordered(int food_type) // Increment appropriate order tally
{
(food_type == 0) ? _cakes_ordered++ : _croissants_ordered++;
}
void TallySheet::Delivered(int food_type) // Increment appropriate delivery tally
{
(food_type == 0) ? _cakes_delivered++ : _croissants_delivered++;
}
void TallySheet::Produced(int food_type) // Increment appropriate produced tally
{
(food_type == 0) ? _cakes_produced++ : _croissants_produced++;
}
void TallySheet::Sold(int food_type) // Increment appropriate sold wtally
{
(food_type == 0) ? _cakes_sold++ : _croissants_sold++;
}
void TallySheet::Discarded(int food_type) // Increment appropriate discarded tally
{
(food_type == 0) ? _cakes_discarded++ : _croissants_discarded++;
}
void TallySheet::Missed(int food_type) // Increment appropriate missed tally
{
(food_type == 0) ? _cakes_missed++ : _croissants_missed++;
}
void TallySheet::Reset(void) // Reset all tally counters
{
_cakes_ordered = 0;
_croissants_ordered = 0;
_cakes_delivered = 0;
_croissants_delivered = 0;
_cakes_produced = 0;
_croissants_produced = 0;
_cakes_sold = 0;
_croissants_sold = 0;
_cakes_discarded = 0;
_croissants_discarded = 0;
_cakes_missed = 0;
_croissants_missed = 0;
}
/******************************************************************************/
/********************************* WRITERS ************************************/
/******************************************************************************/
void TallySheet::WriteReport(ostream &out) // write Daily report to out
{
out << "Ordered raw kits: " << (_cakes_ordered + _croissants_ordered) << endl;
out << "\t#cake " << _cakes_ordered << endl;
out << "\t#croissant " << _croissants_ordered << endl;
out << endl;
out << "Delivered raw kits: " << (_cakes_delivered + _croissants_delivered) << endl;
out << "\t#cake " << _cakes_delivered << endl;
out << "\t#croissant " << _croissants_delivered << endl;
out << endl;
out << "Produced: " << (_cakes_produced + _croissants_produced) << endl;
out << "\t#cake " << _cakes_produced << endl;
out << "\t#croissant " << _croissants_produced << endl;
out << endl;
out << "Sold: " << (_cakes_sold + _croissants_sold) << endl;
out << "\t#cake " << _cakes_sold << endl;
out << "\t#croissant " << _croissants_sold << endl;
out << endl;
out << "Discarded: " << (_cakes_discarded + _croissants_discarded) << endl;
out << "\t#cake " << _cakes_discarded << endl;
out << "\t#croissant " << _croissants_ordered << endl;
out << endl;
out << "Missed Requests: " << (_cakes_missed + _croissants_missed) << endl;
out << "\t#cake " << _cakes_ordered << endl;
out << "\t#croissant " << _croissants_ordered << endl;
out << endl;
}