From ffae2cb77bfb3263146a2de0deedf6528d4df461 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 9 Nov 2022 11:48:12 +0100 Subject: repository aanpassen voor oop2 --- oop1w3/ETer.cpp | 5 +++++ oop1w3/ETer.h | 10 ++++++++++ oop1w3/IBeroep.cpp | 2 ++ oop1w3/IBeroep.h | 13 +++++++++++++ oop1w3/Persoon.cpp | 19 +++++++++++++++++++ oop1w3/Persoon.h | 16 ++++++++++++++++ oop1w3/TIer.cpp | 5 +++++ oop1w3/TIer.h | 10 ++++++++++ oop1w3/main.cpp | 18 ++++++++++++++++++ oop1w3/makefile | 1 + 10 files changed, 99 insertions(+) create mode 100644 oop1w3/ETer.cpp create mode 100644 oop1w3/ETer.h create mode 100644 oop1w3/IBeroep.cpp create mode 100644 oop1w3/IBeroep.h create mode 100644 oop1w3/Persoon.cpp create mode 100644 oop1w3/Persoon.h create mode 100644 oop1w3/TIer.cpp create mode 100644 oop1w3/TIer.h create mode 100644 oop1w3/main.cpp create mode 120000 oop1w3/makefile (limited to 'oop1w3') 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 + +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 + +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 + +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 + +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 + +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 -- cgit v1.2.3