-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
91 lines (74 loc) · 2 KB
/
main.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
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include "Matrix.h"
#include "Vector.h"
#include "Stack.h"
#include "Queens.h"
#include "Queue.h"
using namespace de300;
using namespace std;
void question2 () {
Matrix<int> a(1,2,3,4);
Matrix<int> b(4,3,2,1);
Matrix<int> c(0,0,0,0);
c = a * b;
cout << "multiplying 2 matrices" << "\n"<< c.a<< "\n"<< c.b<< "\n"<< c.c<< "\n"<< c.d << "\n";
}
void question3 () {
Matrix<int> a(1,2,3,4);
Vector<int> v1(1,2);
Vector<int> v2(0,0);
v2 = a * v1;
cout << "multiplying a matrix by a vector" << "\n"<< v2.a<< "\n"<< v2.b << "\n";
}
void question5 () {
Stack<int> myStack;
myStack.push(3);
myStack.push(4);
int s1 = myStack.getHead();
myStack.pop();
int s2 = myStack.getHead();
myStack.pop();
cout << "stack heads" << "\n"<< s1<< "\n"<< s2 << "\n";
}
void question6() {
Queens p;
cout << "Queens’ College foundation (p): " << p.foundation << endl;
Queens q = p;
cout << "Queens’ College foundation (q): " << q.foundation << endl;
Queens r;
r = p;
cout << "Queens’ College foundation (r): " << r.foundation << endl;
}
void question7() {
Queue myQueue;
myQueue.enqueue(5);
myQueue.enqueue(6);
myQueue.enqueue(7);
cout << "queue size after 3 enqueues: " << myQueue.size() << endl;
int x = myQueue.dequeue();
cout << x <<endl;
int y = myQueue.dequeue();
cout << y <<endl;
int z1 = myQueue.peek();
cout << z1 <<endl;
int z2 = myQueue.dequeue();
cout << z2 << endl;
try {
myQueue.enqueue(50);
} catch (EnqueueException e) {
cout << "error code when enqueueing 50: " << e.errorCode <<endl;
}
try {
x = myQueue.dequeue();
} catch (EmptyQueueException e) {
cout << "Successfully threw exception when dequeueing an empty queue" << endl;
}
}
int main(int argc, const char * argv[]) {
question2();
question3();
question5();
question6();
question7();
return 0;
}