-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
95 lines (79 loc) · 2.66 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
92
93
94
95
/*
-------------------------------------------------------------------------------
Laboratoire : Labo1-POO2
Fichier : main.cpp
Auteur(s) : Théo Gallandat & Pierre-Samuel Rochat
Date : 16/03/2017
But : Provide a main method that realise a series of test for the different
implemented operators.
Remarque(s) : R.A.S.
Compilateur : MinGW-g++ 4.8.1
-------------------------------------------------------------------------------
*/
#include <cstdlib>
#include <iostream>
#include <cstdio>
#include "BinaryMatrix.hpp"
#include "Or.hpp"
#include "And.hpp"
#include "Xor.hpp"
using namespace std;
int main() {
Or* opOr = new Or();
And* opAnd = new And();
Xor* opXor = new Xor();
srand(time(0));
cout << "----------------------------------------------------------" << endl;
cout << "Tests of OR operator : " << endl;
cout << "----------------------------------------------------------" << endl;
BinaryMatrix m1(5);
BinaryMatrix m2(5);
cout << "M1 : " << endl;
m1.display();
cout << "M2 : " << endl;
m2.display();
cout << "Return by VALUE : " << endl;
(m1.opReturnVal(m2, *opOr)).display();
cout << "Return by POINTER : " << endl;
(m1.opReturnPtr(m2, *opOr))->display();
cout << "Modification of M1 : " << endl;
m1.opOnMatrix(m2, *opOr);
m1.display();
cout << "----------------------------------------------------------" << endl;
cout << "Tests of AND operator : " << endl;
cout << "----------------------------------------------------------" << endl;
BinaryMatrix m3(5);
BinaryMatrix m4(5);
cout << "M3 : " << endl;
m3.display();
cout << "M4 : " << endl;
m4.display();
cout << "Return by VALUE : " << endl;
(m3.opReturnVal(m4, *opAnd)).display();
cout << "Return by POINTER : " << endl;
(m3.opReturnPtr(m4, *opAnd))->display();
cout << "Modification of M3 : " << endl;
m3.opOnMatrix(m4, *opAnd);
m3.display();
cout << "----------------------------------------------------------" << endl;
cout << "Tests of XOR operator : " << endl;
cout << "----------------------------------------------------------" << endl;
BinaryMatrix m5(5);
BinaryMatrix m6(5);
cout << "M5 : " << endl;
m5.display();
cout << "M6 : " << endl;
m6.display();
cout << "Return by VALUE : " << endl;
(m5.opReturnVal(m6, *opXor)).display();
cout << "Return by POINTER : " << endl;
(m5.opReturnPtr(m6, *opXor))->display();
cout << "Modification of M3 : " << endl;
m5.opOnMatrix(m6, *opXor);
m5.display();
//destruction of the objets used
delete opAnd;
delete opOr;
delete opXor;
return EXIT_SUCCESS;
}