aboutsummaryrefslogtreecommitdiff
path: root/oop1w3
diff options
context:
space:
mode:
Diffstat (limited to 'oop1w3')
-rw-r--r--oop1w3/ETer.cpp5
-rw-r--r--oop1w3/ETer.h10
-rw-r--r--oop1w3/IBeroep.cpp2
-rw-r--r--oop1w3/IBeroep.h13
-rw-r--r--oop1w3/Persoon.cpp19
-rw-r--r--oop1w3/Persoon.h16
-rw-r--r--oop1w3/TIer.cpp5
-rw-r--r--oop1w3/TIer.h10
-rw-r--r--oop1w3/main.cpp18
l---------oop1w3/makefile1
10 files changed, 99 insertions, 0 deletions
diff --git a/oop1w3/ETer.cpp b/oop1w3/ETer.cpp
new file mode 100644
index 0000000..f2eebd0
--- /dev/null
+++ b/oop1w3/ETer.cpp
@@ -0,0 +1,5 @@
+#include "ETer.h"
+
+std::string ETer::getNaam() const {
+ return "ET-er";
+}
diff --git a/oop1w3/ETer.h b/oop1w3/ETer.h
new file mode 100644
index 0000000..9f7ac8f
--- /dev/null
+++ b/oop1w3/ETer.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include "IBeroep.h"
+#include <string>
+
+class ETer : public IBeroep {
+ public:
+ virtual std::string getNaam() const;
+};
+
diff --git a/oop1w3/IBeroep.cpp b/oop1w3/IBeroep.cpp
new file mode 100644
index 0000000..9e4f97e
--- /dev/null
+++ b/oop1w3/IBeroep.cpp
@@ -0,0 +1,2 @@
+#include "IBeroep.h"
+
diff --git a/oop1w3/IBeroep.h b/oop1w3/IBeroep.h
new file mode 100644
index 0000000..8812010
--- /dev/null
+++ b/oop1w3/IBeroep.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <string>
+
+class IBeroep
+{
+public:
+ IBeroep() {}
+ virtual ~IBeroep() {}
+
+public:
+ virtual std::string getNaam() const = 0;
+};
diff --git a/oop1w3/Persoon.cpp b/oop1w3/Persoon.cpp
new file mode 100644
index 0000000..d58028c
--- /dev/null
+++ b/oop1w3/Persoon.cpp
@@ -0,0 +1,19 @@
+#include "Persoon.h"
+
+Persoon::Persoon() {
+ _beroep = NULL;
+}
+
+Persoon::~Persoon() {
+ delete _beroep;
+}
+
+void Persoon::setBeroep(IBeroep* beroep) {
+ delete _beroep;
+ _beroep = beroep;
+}
+
+std::string Persoon::getBeroep() {
+ if (_beroep == NULL) return "geen beroep";
+ return _beroep->getNaam();
+}
diff --git a/oop1w3/Persoon.h b/oop1w3/Persoon.h
new file mode 100644
index 0000000..32ff651
--- /dev/null
+++ b/oop1w3/Persoon.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "IBeroep.h"
+#include <string>
+
+class Persoon {
+ private:
+ IBeroep* _beroep;
+
+ public:
+ virtual void setBeroep(IBeroep* beroep);
+ virtual std::string getBeroep();
+ Persoon();
+ virtual ~Persoon();
+};
+
diff --git a/oop1w3/TIer.cpp b/oop1w3/TIer.cpp
new file mode 100644
index 0000000..801f417
--- /dev/null
+++ b/oop1w3/TIer.cpp
@@ -0,0 +1,5 @@
+#include "TIer.h"
+
+std::string TIer::getNaam() const {
+ return "TI-er";
+}
diff --git a/oop1w3/TIer.h b/oop1w3/TIer.h
new file mode 100644
index 0000000..35147e4
--- /dev/null
+++ b/oop1w3/TIer.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include "IBeroep.h"
+#include <string>
+
+class TIer : public IBeroep {
+ public:
+ virtual std::string getNaam() const;
+};
+
diff --git a/oop1w3/main.cpp b/oop1w3/main.cpp
new file mode 100644
index 0000000..b6b5019
--- /dev/null
+++ b/oop1w3/main.cpp
@@ -0,0 +1,18 @@
+#include "Persoon.h"
+#include "TIer.h"
+#include "ETer.h"
+
+#include <iostream>
+
+int main()
+{
+ Persoon persoon;
+
+ std::cout << persoon.getBeroep() << std::endl; // resultaat: geen beroep
+ persoon.setBeroep( new TIer );
+ std::cout << persoon.getBeroep() << std::endl; // resultaat: TI-er
+ persoon.setBeroep( new ETer );
+ std::cout << persoon.getBeroep() << std::endl; // resultaat: ET-er
+
+ return 0;
+}
diff --git a/oop1w3/makefile b/oop1w3/makefile
new file mode 120000
index 0000000..a4e84c6
--- /dev/null
+++ b/oop1w3/makefile
@@ -0,0 +1 @@
+../week.mk \ No newline at end of file