-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstacker.cpp
48 lines (46 loc) · 949 Bytes
/
stacker.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
// stacker.cpp -- testing the Stack class
#include <iostream>
#include <ctype.h>
#include "stack.h"
int main()
{
using namespace std;
Stack st;
char ch;
unsigned long po;
cout << "Please enter A to add a purchase order. \n"
<< "P to process a PO, or Q to quit.\n";
while (cin >> ch && toupper(ch) != 'Q') {
while (cin.get() != '\n') {
continue;
}
if (!isalpha(ch)) {
cout << '\a';
continue;
}
switch(ch) {
case 'A':
case 'a': cout << "Enter a PO number to add: ";
cin >> po;
if (st.isfull()) {
cout << "stock already full\n";
} else {
st.push(po);
}
break;
case 'P':
case 'p':
if (st.isempty()) {
cout << "stack already empty\n";
} else {
st.pop(po);
cout << "PO #" << po << " popped\n";
}
break;
}
cout << "Please enter A to add a purchase order.\n"
<< "P to process a PO, or Q to quit.\n";
}
cout << "Bye\n";
return 0;
}