aboutsummaryrefslogtreecommitdiff
path: root/oop2w3
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-11-23 10:20:31 +0100
committerlonkaars <loek@pipeframe.xyz>2022-11-23 10:20:31 +0100
commitadb4076e576af4990051ff18f2afd017619d077e (patch)
treecb9bebea353d9bb2abe519d39d32b5d53cb6e433 /oop2w3
parent15d622aa542421c0e3f8eb448b69e1121d7a0738 (diff)
huiswerk week 3 klaar
Diffstat (limited to 'oop2w3')
-rw-r--r--oop2w3/A.cpp25
-rw-r--r--oop2w3/A.h12
-rw-r--r--oop2w3/B.cpp28
-rw-r--r--oop2w3/B.h17
-rw-r--r--oop2w3/C.cpp11
-rw-r--r--oop2w3/C.h8
-rw-r--r--oop2w3/main.cpp15
l---------oop2w3/makefile1
8 files changed, 117 insertions, 0 deletions
diff --git a/oop2w3/A.cpp b/oop2w3/A.cpp
new file mode 100644
index 0000000..b6f0d57
--- /dev/null
+++ b/oop2w3/A.cpp
@@ -0,0 +1,25 @@
+#include <iostream>
+
+#include "A.h"
+
+A::A() {
+ std::cout << "A::A()" << std::endl;
+ _b = nullptr;
+}
+
+void A::actie1(int n) {
+ std::cout << "A::actie1(" << n << ")" << std::endl;
+ for (unsigned int i = 0; i <= n; i++) {
+ if (i % 2 == 0) {
+ _b->even();
+ } else {
+ _b->odd(i);
+ }
+ }
+}
+
+void A::setB(B b) {
+ std::cout << "A::setB(b)" << std::endl;
+ _b = &b;
+}
+
diff --git a/oop2w3/A.h b/oop2w3/A.h
new file mode 100644
index 0000000..c0caae4
--- /dev/null
+++ b/oop2w3/A.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "B.h"
+
+class A {
+ private:
+ B* _b;
+ public:
+ A();
+ virtual void setB(B b);
+ virtual void actie1(int n);
+};
diff --git a/oop2w3/B.cpp b/oop2w3/B.cpp
new file mode 100644
index 0000000..6eb4bd2
--- /dev/null
+++ b/oop2w3/B.cpp
@@ -0,0 +1,28 @@
+#include <iostream>
+
+#include "A.h"
+#include "B.h"
+
+B::B(A a) {
+ std::cout << "B::B(a)" << std::endl;
+ _a = &a;
+ _c = new C();
+}
+
+void B::even() {
+ std::cout << "B::even()" << std::endl;
+}
+
+void B::odd(int i) {
+ std::cout << "B::odd(" << i << ")" << std::endl;
+}
+
+void B::actie2(int i) {
+ std::cout << "B::actie2(" << i << ")" << std::endl;
+ actie3();
+ if (i < 3) _c->actie4();
+}
+
+void B::actie3() {
+ std::cout << "B::actie3()" << std::endl;
+}
diff --git a/oop2w3/B.h b/oop2w3/B.h
new file mode 100644
index 0000000..081dc8b
--- /dev/null
+++ b/oop2w3/B.h
@@ -0,0 +1,17 @@
+#pragma once
+
+class A;
+#include "C.h"
+
+class B {
+ private:
+ A* _a;
+ C* _c;
+ public:
+ B(A a);
+ virtual void even();
+ virtual void odd(int i);
+ virtual void actie2(int i);
+ virtual void actie3();
+};
+
diff --git a/oop2w3/C.cpp b/oop2w3/C.cpp
new file mode 100644
index 0000000..6a0fadd
--- /dev/null
+++ b/oop2w3/C.cpp
@@ -0,0 +1,11 @@
+#include <iostream>
+
+#include "C.h"
+
+C::C() {
+ std::cout << "C::C()" << std::endl;
+}
+
+void C::actie4() {
+ std::cout << "C::actie4()" << std::endl;
+}
diff --git a/oop2w3/C.h b/oop2w3/C.h
new file mode 100644
index 0000000..1e22eb1
--- /dev/null
+++ b/oop2w3/C.h
@@ -0,0 +1,8 @@
+#pragma once
+
+class C {
+ public:
+ C();
+ virtual void actie4();
+};
+
diff --git a/oop2w3/main.cpp b/oop2w3/main.cpp
new file mode 100644
index 0000000..90a88b6
--- /dev/null
+++ b/oop2w3/main.cpp
@@ -0,0 +1,15 @@
+#include <iostream>
+
+#include "A.h"
+#include "B.h"
+
+int main() {
+ std::cout << "main()" << std::endl;
+ int n = 2;
+ A a;
+ B b(a);
+ a.setB(b);
+ a.actie1(n);
+ b.actie2(n);
+ return 0;
+}
diff --git a/oop2w3/makefile b/oop2w3/makefile
new file mode 120000
index 0000000..a4e84c6
--- /dev/null
+++ b/oop2w3/makefile
@@ -0,0 +1 @@
+../week.mk \ No newline at end of file