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 --- .gitignore | 2 ++ makefile | 19 +++++-------- oop1w1/Opteller.cpp | 13 +++++++++ oop1w1/Opteller.h | 12 ++++++++ oop1w1/main.cpp | 24 ++++++++++++++++ oop1w1/makefile | 1 + oop1w2/Driehoek.cpp | 15 ++++++++++ oop1w2/Driehoek.h | 13 +++++++++ oop1w2/Rechthoek.cpp | 14 ++++++++++ oop1w2/Rechthoek.h | 13 +++++++++ oop1w2/Vorm.cpp | 13 +++++++++ oop1w2/Vorm.h | 9 ++++++ oop1w2/main.cpp | 21 ++++++++++++++ oop1w2/makefile | 1 + 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 + oop1w4/Persoon.cpp | 22 +++++++++++++++ oop1w4/Persoon.h | 16 +++++++++++ oop1w4/Spel.cpp | 29 +++++++++++++++++++ oop1w4/Spel.h | 18 ++++++++++++ oop1w4/main.cpp | 26 +++++++++++++++++ oop1w4/makefile | 1 + oop1w5/StringWeek5.cpp | 12 ++++++++ oop1w5/StringWeek5.h | 16 +++++++++++ oop1w5/StringWeek5.hpp | 12 ++++++++ oop1w5/main.cpp | 20 ++++++++++++++ oop1w5/makefile | 1 + oop1w6/Punt.cpp | 17 ++++++++++++ oop1w6/Punt.h | 17 ++++++++++++ oop1w6/PuntContainer.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ oop1w6/PuntContainer.h | 35 +++++++++++++++++++++++ oop1w6/main.cpp | 23 ++++++++++++++++ oop1w6/makefile | 1 + readme.md | 12 ++++++++ week-1/Opteller.cpp | 13 --------- week-1/Opteller.h | 12 -------- week-1/main.cpp | 24 ---------------- week-1/makefile | 1 - week-2/Driehoek.cpp | 15 ---------- week-2/Driehoek.h | 13 --------- week-2/Rechthoek.cpp | 14 ---------- week-2/Rechthoek.h | 13 --------- week-2/Vorm.cpp | 13 --------- week-2/Vorm.h | 9 ------ week-2/main.cpp | 21 -------------- week-2/makefile | 1 - week-3/ETer.cpp | 5 ---- week-3/ETer.h | 10 ------- week-3/IBeroep.cpp | 2 -- week-3/IBeroep.h | 13 --------- week-3/Persoon.cpp | 19 ------------- week-3/Persoon.h | 16 ----------- week-3/TIer.cpp | 5 ---- week-3/TIer.h | 10 ------- week-3/main.cpp | 18 ------------ week-3/makefile | 1 - week-4/Persoon.cpp | 22 --------------- week-4/Persoon.h | 16 ----------- week-4/Spel.cpp | 29 ------------------- week-4/Spel.h | 18 ------------ week-4/main.cpp | 26 ----------------- week-4/makefile | 1 - week-5/StringWeek5.cpp | 12 -------- week-5/StringWeek5.h | 16 ----------- week-5/StringWeek5.hpp | 12 -------- week-5/main.cpp | 20 -------------- week-5/makefile | 1 - week-6/Punt.cpp | 17 ------------ week-6/Punt.h | 17 ------------ week-6/PuntContainer.cpp | 72 ------------------------------------------------ week-6/PuntContainer.h | 35 ----------------------- week-6/main.cpp | 23 ---------------- week-6/makefile | 1 - 81 files changed, 607 insertions(+), 598 deletions(-) create mode 100644 oop1w1/Opteller.cpp create mode 100644 oop1w1/Opteller.h create mode 100644 oop1w1/main.cpp create mode 120000 oop1w1/makefile create mode 100644 oop1w2/Driehoek.cpp create mode 100644 oop1w2/Driehoek.h create mode 100644 oop1w2/Rechthoek.cpp create mode 100644 oop1w2/Rechthoek.h create mode 100644 oop1w2/Vorm.cpp create mode 100644 oop1w2/Vorm.h create mode 100644 oop1w2/main.cpp create mode 120000 oop1w2/makefile 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 create mode 100644 oop1w4/Persoon.cpp create mode 100644 oop1w4/Persoon.h create mode 100644 oop1w4/Spel.cpp create mode 100644 oop1w4/Spel.h create mode 100644 oop1w4/main.cpp create mode 120000 oop1w4/makefile create mode 100644 oop1w5/StringWeek5.cpp create mode 100644 oop1w5/StringWeek5.h create mode 100644 oop1w5/StringWeek5.hpp create mode 100644 oop1w5/main.cpp create mode 120000 oop1w5/makefile create mode 100644 oop1w6/Punt.cpp create mode 100644 oop1w6/Punt.h create mode 100644 oop1w6/PuntContainer.cpp create mode 100644 oop1w6/PuntContainer.h create mode 100644 oop1w6/main.cpp create mode 120000 oop1w6/makefile create mode 100644 readme.md delete mode 100644 week-1/Opteller.cpp delete mode 100644 week-1/Opteller.h delete mode 100644 week-1/main.cpp delete mode 120000 week-1/makefile delete mode 100644 week-2/Driehoek.cpp delete mode 100644 week-2/Driehoek.h delete mode 100644 week-2/Rechthoek.cpp delete mode 100644 week-2/Rechthoek.h delete mode 100644 week-2/Vorm.cpp delete mode 100644 week-2/Vorm.h delete mode 100644 week-2/main.cpp delete mode 120000 week-2/makefile delete mode 100644 week-3/ETer.cpp delete mode 100644 week-3/ETer.h delete mode 100644 week-3/IBeroep.cpp delete mode 100644 week-3/IBeroep.h delete mode 100644 week-3/Persoon.cpp delete mode 100644 week-3/Persoon.h delete mode 100644 week-3/TIer.cpp delete mode 100644 week-3/TIer.h delete mode 100644 week-3/main.cpp delete mode 120000 week-3/makefile delete mode 100644 week-4/Persoon.cpp delete mode 100644 week-4/Persoon.h delete mode 100644 week-4/Spel.cpp delete mode 100644 week-4/Spel.h delete mode 100644 week-4/main.cpp delete mode 120000 week-4/makefile delete mode 100644 week-5/StringWeek5.cpp delete mode 100644 week-5/StringWeek5.h delete mode 100644 week-5/StringWeek5.hpp delete mode 100644 week-5/main.cpp delete mode 120000 week-5/makefile delete mode 100644 week-6/Punt.cpp delete mode 100644 week-6/Punt.h delete mode 100644 week-6/PuntContainer.cpp delete mode 100644 week-6/PuntContainer.h delete mode 100644 week-6/main.cpp delete mode 120000 week-6/makefile diff --git a/.gitignore b/.gitignore index aca116d..4cf3fc4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/*.pdf **/main **/compile_commands.json +**/.cache + diff --git a/makefile b/makefile index 4e05b91..acb6c56 100644 --- a/makefile +++ b/makefile @@ -1,16 +1,11 @@ MK = make -j -WEKEN = $(wildcard week-*) +WEKEN := $(wildcard oop*w*) +TARGETS := all clean compile_commands zip -submake = $(foreach WEEK,$(WEKEN), $(MK) -C $(WEEK) $(1);) +_: all -all: - $(call submake) +.PHONY: $(TARGETS) $(WEKEN) +$(TARGETS): $(WEKEN) +$(WEKEN): + $(MK) -C $@ $(MAKECMDGOALS) -clean: - $(call submake, clean) - -compile_commands: - $(call submake, compile_commands) - -zip: - $(call submake, zip) diff --git a/oop1w1/Opteller.cpp b/oop1w1/Opteller.cpp new file mode 100644 index 0000000..41efee0 --- /dev/null +++ b/oop1w1/Opteller.cpp @@ -0,0 +1,13 @@ +#include "Opteller.h" + +void Opteller::initialiseer() { + som = 0; +} + +void Opteller::voegWaardeToe(int waarde) { + som += waarde; +} + +int Opteller::geefSom() { + return som; +} diff --git a/oop1w1/Opteller.h b/oop1w1/Opteller.h new file mode 100644 index 0000000..2f21d79 --- /dev/null +++ b/oop1w1/Opteller.h @@ -0,0 +1,12 @@ +#pragma once + +class Opteller { + private: + int som; + + public: + void initialiseer(); + void voegWaardeToe(int waarde); + int geefSom(); +}; + diff --git a/oop1w1/main.cpp b/oop1w1/main.cpp new file mode 100644 index 0000000..0d895f4 --- /dev/null +++ b/oop1w1/main.cpp @@ -0,0 +1,24 @@ +/* + * Do not adapt this file!!! + */ + + +#include "Opteller.h" +#include + +int main() +{ + Opteller opteller; + + opteller.initialiseer(); // zet som op 0 + opteller.voegWaardeToe( 1 ); // tel 1 erbij + opteller.voegWaardeToe( 2 ); // tel 2 erbij + opteller.voegWaardeToe( 3 ); // tel 3 erbij + opteller.voegWaardeToe( 4 ); // tel 4 erbij + opteller.voegWaardeToe( 5 ); // tel 5 erbij + + std::cout << opteller.geefSom() << std::endl; // toon de som + std::cin.get(); // wacht op + + return 0; +} \ No newline at end of file diff --git a/oop1w1/makefile b/oop1w1/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop1w1/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file diff --git a/oop1w2/Driehoek.cpp b/oop1w2/Driehoek.cpp new file mode 100644 index 0000000..1c1323c --- /dev/null +++ b/oop1w2/Driehoek.cpp @@ -0,0 +1,15 @@ +#include "Driehoek.h" + +Driehoek::Driehoek(double b, double h) { + breedte = b; + hoogte = h; +} + +double Driehoek::getSomGraden() { + return 180; +} + +double Driehoek::getOppervlakte() { + return breedte * hoogte * 0.5f; +} + diff --git a/oop1w2/Driehoek.h b/oop1w2/Driehoek.h new file mode 100644 index 0000000..f8a3a37 --- /dev/null +++ b/oop1w2/Driehoek.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Vorm.h" + +class Driehoek : public Vorm { + public: + Driehoek(double breedte, double hoogte); + virtual double getOppervlakte(); + virtual double getSomGraden(); + private: + double breedte; + double hoogte; +}; diff --git a/oop1w2/Rechthoek.cpp b/oop1w2/Rechthoek.cpp new file mode 100644 index 0000000..1f7b313 --- /dev/null +++ b/oop1w2/Rechthoek.cpp @@ -0,0 +1,14 @@ +#include "Rechthoek.h" + +Rechthoek::Rechthoek(double b, double h) { + breedte = b; + hoogte = h; +} + +double Rechthoek::getSomGraden() { + return 360; +} + +double Rechthoek::getOppervlakte() { + return breedte * hoogte; +} diff --git a/oop1w2/Rechthoek.h b/oop1w2/Rechthoek.h new file mode 100644 index 0000000..4f526f9 --- /dev/null +++ b/oop1w2/Rechthoek.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Vorm.h" + +class Rechthoek : public Vorm { + public: + Rechthoek(double breedte, double hoogte); + virtual double getSomGraden(); + virtual double getOppervlakte(); + private: + double breedte; + double hoogte; +}; diff --git a/oop1w2/Vorm.cpp b/oop1w2/Vorm.cpp new file mode 100644 index 0000000..c919d08 --- /dev/null +++ b/oop1w2/Vorm.cpp @@ -0,0 +1,13 @@ +#include "Vorm.h" + +Vorm::Vorm() { + return; +} + +double Vorm::getOppervlakte() { + return 0; +} + +double Vorm::getSomGraden() { + return 0; +} diff --git a/oop1w2/Vorm.h b/oop1w2/Vorm.h new file mode 100644 index 0000000..17cf486 --- /dev/null +++ b/oop1w2/Vorm.h @@ -0,0 +1,9 @@ +#pragma once + +class Vorm { + public: + Vorm(); + virtual double getOppervlakte(); + virtual double getSomGraden(); +}; + diff --git a/oop1w2/main.cpp b/oop1w2/main.cpp new file mode 100644 index 0000000..69db85b --- /dev/null +++ b/oop1w2/main.cpp @@ -0,0 +1,21 @@ +/* + * Do not adapt this file!!! + */ +#include "Driehoek.h" +#include "Rechthoek.h" + +#include + +int main() +{ + Vorm *driehoek = new Driehoek( 6.0, 8.0 ); + Vorm *rechthoek = new Rechthoek( 6.0, 8.0 ); + + std::cout << driehoek ->getOppervlakte() << " " << driehoek ->getSomGraden() << std::endl; + std::cout << rechthoek->getOppervlakte() << " " << rechthoek->getSomGraden() << std::endl; + + delete driehoek; + delete rechthoek; + + return 0; +} diff --git a/oop1w2/makefile b/oop1w2/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop1w2/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file 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 diff --git a/oop1w4/Persoon.cpp b/oop1w4/Persoon.cpp new file mode 100644 index 0000000..de5195d --- /dev/null +++ b/oop1w4/Persoon.cpp @@ -0,0 +1,22 @@ +#include "Persoon.h" + +bool Persoon::operator < ( const Persoon& persoon ) const { + return naam < persoon.naam; +} + +Persoon::Persoon(std::string naam) { + this->naam = naam; +} + +const std::string& Persoon::getNaam() const { + return naam; +} + +int Persoon::getLeeftijd() const { + return leeftijd; +} + +void Persoon::setLeeftijd(int leeftijd) { + this->leeftijd = leeftijd; +} + diff --git a/oop1w4/Persoon.h b/oop1w4/Persoon.h new file mode 100644 index 0000000..df4a3f2 --- /dev/null +++ b/oop1w4/Persoon.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +class Persoon { + public: + Persoon(std::string naam); + const std::string& getNaam() const; + int getLeeftijd() const; + void setLeeftijd(int leeftijd); + bool operator < (const Persoon& other) const; + + private: + std::string naam; + int leeftijd; +}; diff --git a/oop1w4/Spel.cpp b/oop1w4/Spel.cpp new file mode 100644 index 0000000..5ddc355 --- /dev/null +++ b/oop1w4/Spel.cpp @@ -0,0 +1,29 @@ +#include "Spel.h" + +Persoon* Spel::getPersoon(const std::string naam) const { + auto iFind = scores.find(naam); + if (iFind == scores.end()) + return nullptr; + else + return const_cast(&iFind->first); +} + +void Spel::setScore(std::string naam, int score) { + scores[naam] = score; +} + +void Spel::addScore(std::string naam, int score) { + scores[naam] += score; +} + +int Spel::getScore(std::string naam) const { + auto iFind = scores.find(naam); + if (iFind == scores.end()) + return 0; + else + return iFind->second; +} + +std::map& Spel::getScores() { + return scores; +} diff --git a/oop1w4/Spel.h b/oop1w4/Spel.h new file mode 100644 index 0000000..9ed04ba --- /dev/null +++ b/oop1w4/Spel.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +#include "Persoon.h" + +class Spel { + public: + void setScore(std::string naam, int score); + void addScore(std::string naam, int score); + int getScore(std::string naam) const; + Persoon* getPersoon(std::string naam) const; + std::map& getScores(); + + private: + std::map scores; +}; diff --git a/oop1w4/main.cpp b/oop1w4/main.cpp new file mode 100644 index 0000000..b81a711 --- /dev/null +++ b/oop1w4/main.cpp @@ -0,0 +1,26 @@ +#include "Spel.h" +#include "Persoon.h" + +#include + +int main() +{ + Spel spel; + spel.setScore("Bert", 15); + std::cout << spel.getScore("Bert") << std::endl; // uikomst: 15 + Persoon *bert = spel.getPersoon("Bert"); + bert->setLeeftijd(103); + spel.addScore("Bert", 16); + std::cout << spel.getScore("Bert") << std::endl; // uikomst: 31 + bert = spel.getPersoon("Bert"); + std::cout << bert->getLeeftijd() << std::endl; // uikomst: 103 + spel.setScore("Joan", 512); + spel.setScore("Arthur", 1024); + for ( auto pair : spel.getScores() ) + { + std::cout << pair.first.getNaam() << "\t" + << pair.first.getLeeftijd() << "\t" + << pair.second << std::endl; + } + return 0; +} diff --git a/oop1w4/makefile b/oop1w4/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop1w4/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file diff --git a/oop1w5/StringWeek5.cpp b/oop1w5/StringWeek5.cpp new file mode 100644 index 0000000..ae8ba9f --- /dev/null +++ b/oop1w5/StringWeek5.cpp @@ -0,0 +1,12 @@ +#include + +#include "StringWeek5.h" + +void StringWeek5::removeAll(const std::string& remove) { + this->text = std::regex_replace(this->text, std::regex(remove), ""); +} + +const std::string& StringWeek5::getText() const { + return this->text; +} + diff --git a/oop1w5/StringWeek5.h b/oop1w5/StringWeek5.h new file mode 100644 index 0000000..8c2bdac --- /dev/null +++ b/oop1w5/StringWeek5.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +class StringWeek5 { +public: + template + void add(const T& value); + void removeAll(const std::string& remove); + const std::string& getText() const; +private: + std::string text; +}; + +#include "StringWeek5.hpp" diff --git a/oop1w5/StringWeek5.hpp b/oop1w5/StringWeek5.hpp new file mode 100644 index 0000000..ed71e75 --- /dev/null +++ b/oop1w5/StringWeek5.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "StringWeek5.h" +#include + +template +void StringWeek5::add(const T& value) { + std::stringstream value_str(""); + value_str << value; + this->text.append(value_str.str()); +} + diff --git a/oop1w5/main.cpp b/oop1w5/main.cpp new file mode 100644 index 0000000..a2603fa --- /dev/null +++ b/oop1w5/main.cpp @@ -0,0 +1,20 @@ +#include "StringWeek5.h" + +#include + +int main() { + StringWeek5 myString; + + myString.add("hallo allemaal "); + myString.add(42); + myString.add(" "); + myString.add(3.14159265358979); + + std::cout << myString.getText() << std::endl; + + myString.removeAll("all"); + + std::cout << myString.getText() << std::endl << std::endl; + + return 0; +} diff --git a/oop1w5/makefile b/oop1w5/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop1w5/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file diff --git a/oop1w6/Punt.cpp b/oop1w6/Punt.cpp new file mode 100644 index 0000000..707047e --- /dev/null +++ b/oop1w6/Punt.cpp @@ -0,0 +1,17 @@ +#include "Punt.h" + +Punt::Punt() { + this->x = this->y = this->z = 0; +} + +Punt::Punt(int x, int y, int z) { + this->x = x; + this->y = y; + this->z = z; +} + +std::ostream& operator << ( std::ostream& output, const Punt& punt ) { + output << "(" << punt.x << "," << punt.y << "," << punt.z << ")"; + return output; +} + diff --git a/oop1w6/Punt.h b/oop1w6/Punt.h new file mode 100644 index 0000000..b56e798 --- /dev/null +++ b/oop1w6/Punt.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +class Punt +{ +private: + Punt(); + Punt( int x, int y, int z ); + + friend std::ostream& operator << ( std::ostream& output, const Punt& punt ); + +private: + int x, y, z; + + friend class PuntContainer; +}; diff --git a/oop1w6/PuntContainer.cpp b/oop1w6/PuntContainer.cpp new file mode 100644 index 0000000..e673472 --- /dev/null +++ b/oop1w6/PuntContainer.cpp @@ -0,0 +1,72 @@ +#include + +#include "PuntContainer.h" +#include "Punt.h" + +int PuntContainer::checkX(const Punt& punt1, const Punt& punt2) { + return punt1.x - punt2.x; +} + +int PuntContainer::checkY(const Punt& punt1, const Punt& punt2) { + return punt1.y - punt2.y; +} + +int PuntContainer::checkZ(const Punt& punt1, const Punt& punt2) { + return punt1.z - punt2.z; +} + +int PuntContainer::checkX2(const Punt& punt1, const Punt& punt2) const { + return punt1.x - punt2.x; +} + +int PuntContainer::checkY2(const Punt& punt1, const Punt& punt2) const { + return punt1.y - punt2.y; +} + +int PuntContainer::checkZ2(const Punt& punt1, const Punt& punt2) const { + return punt1.z - punt2.z; +} + +PuntContainer::PuntContainer() { + this->puntRij = (Punt*) malloc(sizeof(Punt) * 10); + this->grootte = 0; +} + +PuntContainer::~PuntContainer() { + free(this->puntRij); +} + +void PuntContainer::add(int x, int y, int z) { + puntRij[grootte].x = x; + puntRij[grootte].y = y; + puntRij[grootte].z = z; + grootte++; +} + +void PuntContainer::sort1(int (*fnCompare)(const Punt&, const Punt&)) { + for ( uint32_t outer = grootte-1; outer > 0; outer-- ) + for ( uint32_t inner=0; inner < outer; inner++ ) + if ( (*fnCompare)(puntRij[inner],puntRij[inner+1]) > 0 ) { + Punt temp = puntRij[inner]; + puntRij[inner] = puntRij[inner+1]; + puntRij[inner+1] = temp; + } +} + +void PuntContainer::sort2(int (PuntContainer::*fnCompare)(const Punt&, const Punt&) const) { + for ( uint32_t outer = grootte-1; outer > 0; outer-- ) + for ( uint32_t inner=0; inner < outer; inner++ ) { + if ( (*this.*fnCompare)(puntRij[inner],puntRij[inner+1]) > 0 ) { + Punt temp = puntRij[inner]; + puntRij[inner] = puntRij[inner+1]; + puntRij[inner+1] = temp; + } + } +} + +void PuntContainer::showAll() { + for (uint32_t i = 0; i < this->grootte; i++) + std::cout << this->puntRij[i] << std::endl; + std::cout << std::endl; +} + diff --git a/oop1w6/PuntContainer.h b/oop1w6/PuntContainer.h new file mode 100644 index 0000000..58c7875 --- /dev/null +++ b/oop1w6/PuntContainer.h @@ -0,0 +1,35 @@ +#pragma once + +class Punt; + +#include + +class PuntContainer +{ +public: + PuntContainer(); + virtual ~PuntContainer(); + +public: + virtual void add( int x, int y, int z ); + + virtual void sort1( int (*)( const Punt&, const Punt&) ); + virtual void sort2( int (PuntContainer::*)( const Punt&, const Punt&) const ); + + virtual void showAll(); + +public: + static int checkX( const Punt& punt1, const Punt& punt2 ); + static int checkY( const Punt& punt1, const Punt& punt2 ); + static int checkZ( const Punt& punt1, const Punt& punt2 ); + +public: + virtual int checkX2( const Punt& punt1, const Punt& punt2 ) const; + virtual int checkY2( const Punt& punt1, const Punt& punt2 ) const; + virtual int checkZ2( const Punt& punt1, const Punt& punt2 ) const; + +private: + Punt* puntRij; + uint32_t grootte; +}; + diff --git a/oop1w6/main.cpp b/oop1w6/main.cpp new file mode 100644 index 0000000..701ac33 --- /dev/null +++ b/oop1w6/main.cpp @@ -0,0 +1,23 @@ +#include "PuntContainer.h" + +#include + +int main() +{ + PuntContainer container; + + container.add( 1, 3, 4 ); + container.add( 3, 2, 1 ); + container.add( 2, 4, 2 ); + + container.sort2( &PuntContainer::checkZ2 ); + container.showAll(); + + container.sort2( &PuntContainer::checkY2 ); + container.showAll(); + + container.sort2( &PuntContainer::checkX2 ); + container.showAll(); + + return 0; +} diff --git a/oop1w6/makefile b/oop1w6/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop1w6/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..38134e7 --- /dev/null +++ b/readme.md @@ -0,0 +1,12 @@ +# oop huiswerk + +hier staan de uitwerkingen van de huiswerkopgaven voor object-georiƫnteerd +programmeren 1 en 2. de mapnamen zijn `oop<1 of 2>w`. gelieve als +naslagwerk te gebruiken. + +deze map bevat een makefile die alle weekopdrachten tegelijk kan compileren, +terwijl elke week een makefile heeft die een snelkoppeling is naar week.mk. er +zijn voor de rest geen rare uitzonderingen bij compileren, dus waarschijnlijk +kunnen deze bronbestanden ook met weinig aanpassingen compileren in IDE's als +Eclipse of Visual Studio Community. + diff --git a/week-1/Opteller.cpp b/week-1/Opteller.cpp deleted file mode 100644 index 41efee0..0000000 --- a/week-1/Opteller.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Opteller.h" - -void Opteller::initialiseer() { - som = 0; -} - -void Opteller::voegWaardeToe(int waarde) { - som += waarde; -} - -int Opteller::geefSom() { - return som; -} diff --git a/week-1/Opteller.h b/week-1/Opteller.h deleted file mode 100644 index 2f21d79..0000000 --- a/week-1/Opteller.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -class Opteller { - private: - int som; - - public: - void initialiseer(); - void voegWaardeToe(int waarde); - int geefSom(); -}; - diff --git a/week-1/main.cpp b/week-1/main.cpp deleted file mode 100644 index 0d895f4..0000000 --- a/week-1/main.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Do not adapt this file!!! - */ - - -#include "Opteller.h" -#include - -int main() -{ - Opteller opteller; - - opteller.initialiseer(); // zet som op 0 - opteller.voegWaardeToe( 1 ); // tel 1 erbij - opteller.voegWaardeToe( 2 ); // tel 2 erbij - opteller.voegWaardeToe( 3 ); // tel 3 erbij - opteller.voegWaardeToe( 4 ); // tel 4 erbij - opteller.voegWaardeToe( 5 ); // tel 5 erbij - - std::cout << opteller.geefSom() << std::endl; // toon de som - std::cin.get(); // wacht op - - return 0; -} \ No newline at end of file diff --git a/week-1/makefile b/week-1/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-1/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file diff --git a/week-2/Driehoek.cpp b/week-2/Driehoek.cpp deleted file mode 100644 index 1c1323c..0000000 --- a/week-2/Driehoek.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Driehoek.h" - -Driehoek::Driehoek(double b, double h) { - breedte = b; - hoogte = h; -} - -double Driehoek::getSomGraden() { - return 180; -} - -double Driehoek::getOppervlakte() { - return breedte * hoogte * 0.5f; -} - diff --git a/week-2/Driehoek.h b/week-2/Driehoek.h deleted file mode 100644 index f8a3a37..0000000 --- a/week-2/Driehoek.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Vorm.h" - -class Driehoek : public Vorm { - public: - Driehoek(double breedte, double hoogte); - virtual double getOppervlakte(); - virtual double getSomGraden(); - private: - double breedte; - double hoogte; -}; diff --git a/week-2/Rechthoek.cpp b/week-2/Rechthoek.cpp deleted file mode 100644 index 1f7b313..0000000 --- a/week-2/Rechthoek.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Rechthoek.h" - -Rechthoek::Rechthoek(double b, double h) { - breedte = b; - hoogte = h; -} - -double Rechthoek::getSomGraden() { - return 360; -} - -double Rechthoek::getOppervlakte() { - return breedte * hoogte; -} diff --git a/week-2/Rechthoek.h b/week-2/Rechthoek.h deleted file mode 100644 index 4f526f9..0000000 --- a/week-2/Rechthoek.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Vorm.h" - -class Rechthoek : public Vorm { - public: - Rechthoek(double breedte, double hoogte); - virtual double getSomGraden(); - virtual double getOppervlakte(); - private: - double breedte; - double hoogte; -}; diff --git a/week-2/Vorm.cpp b/week-2/Vorm.cpp deleted file mode 100644 index c919d08..0000000 --- a/week-2/Vorm.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Vorm.h" - -Vorm::Vorm() { - return; -} - -double Vorm::getOppervlakte() { - return 0; -} - -double Vorm::getSomGraden() { - return 0; -} diff --git a/week-2/Vorm.h b/week-2/Vorm.h deleted file mode 100644 index 17cf486..0000000 --- a/week-2/Vorm.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -class Vorm { - public: - Vorm(); - virtual double getOppervlakte(); - virtual double getSomGraden(); -}; - diff --git a/week-2/main.cpp b/week-2/main.cpp deleted file mode 100644 index 69db85b..0000000 --- a/week-2/main.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Do not adapt this file!!! - */ -#include "Driehoek.h" -#include "Rechthoek.h" - -#include - -int main() -{ - Vorm *driehoek = new Driehoek( 6.0, 8.0 ); - Vorm *rechthoek = new Rechthoek( 6.0, 8.0 ); - - std::cout << driehoek ->getOppervlakte() << " " << driehoek ->getSomGraden() << std::endl; - std::cout << rechthoek->getOppervlakte() << " " << rechthoek->getSomGraden() << std::endl; - - delete driehoek; - delete rechthoek; - - return 0; -} diff --git a/week-2/makefile b/week-2/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-2/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file diff --git a/week-3/ETer.cpp b/week-3/ETer.cpp deleted file mode 100644 index f2eebd0..0000000 --- a/week-3/ETer.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "ETer.h" - -std::string ETer::getNaam() const { - return "ET-er"; -} diff --git a/week-3/ETer.h b/week-3/ETer.h deleted file mode 100644 index 9f7ac8f..0000000 --- a/week-3/ETer.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "IBeroep.h" -#include - -class ETer : public IBeroep { - public: - virtual std::string getNaam() const; -}; - diff --git a/week-3/IBeroep.cpp b/week-3/IBeroep.cpp deleted file mode 100644 index 9e4f97e..0000000 --- a/week-3/IBeroep.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "IBeroep.h" - diff --git a/week-3/IBeroep.h b/week-3/IBeroep.h deleted file mode 100644 index 8812010..0000000 --- a/week-3/IBeroep.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -class IBeroep -{ -public: - IBeroep() {} - virtual ~IBeroep() {} - -public: - virtual std::string getNaam() const = 0; -}; diff --git a/week-3/Persoon.cpp b/week-3/Persoon.cpp deleted file mode 100644 index d58028c..0000000 --- a/week-3/Persoon.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#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/week-3/Persoon.h b/week-3/Persoon.h deleted file mode 100644 index 32ff651..0000000 --- a/week-3/Persoon.h +++ /dev/null @@ -1,16 +0,0 @@ -#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/week-3/TIer.cpp b/week-3/TIer.cpp deleted file mode 100644 index 801f417..0000000 --- a/week-3/TIer.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "TIer.h" - -std::string TIer::getNaam() const { - return "TI-er"; -} diff --git a/week-3/TIer.h b/week-3/TIer.h deleted file mode 100644 index 35147e4..0000000 --- a/week-3/TIer.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "IBeroep.h" -#include - -class TIer : public IBeroep { - public: - virtual std::string getNaam() const; -}; - diff --git a/week-3/main.cpp b/week-3/main.cpp deleted file mode 100644 index b6b5019..0000000 --- a/week-3/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#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/week-3/makefile b/week-3/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-3/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file diff --git a/week-4/Persoon.cpp b/week-4/Persoon.cpp deleted file mode 100644 index de5195d..0000000 --- a/week-4/Persoon.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Persoon.h" - -bool Persoon::operator < ( const Persoon& persoon ) const { - return naam < persoon.naam; -} - -Persoon::Persoon(std::string naam) { - this->naam = naam; -} - -const std::string& Persoon::getNaam() const { - return naam; -} - -int Persoon::getLeeftijd() const { - return leeftijd; -} - -void Persoon::setLeeftijd(int leeftijd) { - this->leeftijd = leeftijd; -} - diff --git a/week-4/Persoon.h b/week-4/Persoon.h deleted file mode 100644 index df4a3f2..0000000 --- a/week-4/Persoon.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -class Persoon { - public: - Persoon(std::string naam); - const std::string& getNaam() const; - int getLeeftijd() const; - void setLeeftijd(int leeftijd); - bool operator < (const Persoon& other) const; - - private: - std::string naam; - int leeftijd; -}; diff --git a/week-4/Spel.cpp b/week-4/Spel.cpp deleted file mode 100644 index 5ddc355..0000000 --- a/week-4/Spel.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "Spel.h" - -Persoon* Spel::getPersoon(const std::string naam) const { - auto iFind = scores.find(naam); - if (iFind == scores.end()) - return nullptr; - else - return const_cast(&iFind->first); -} - -void Spel::setScore(std::string naam, int score) { - scores[naam] = score; -} - -void Spel::addScore(std::string naam, int score) { - scores[naam] += score; -} - -int Spel::getScore(std::string naam) const { - auto iFind = scores.find(naam); - if (iFind == scores.end()) - return 0; - else - return iFind->second; -} - -std::map& Spel::getScores() { - return scores; -} diff --git a/week-4/Spel.h b/week-4/Spel.h deleted file mode 100644 index 9ed04ba..0000000 --- a/week-4/Spel.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include - -#include "Persoon.h" - -class Spel { - public: - void setScore(std::string naam, int score); - void addScore(std::string naam, int score); - int getScore(std::string naam) const; - Persoon* getPersoon(std::string naam) const; - std::map& getScores(); - - private: - std::map scores; -}; diff --git a/week-4/main.cpp b/week-4/main.cpp deleted file mode 100644 index b81a711..0000000 --- a/week-4/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Spel.h" -#include "Persoon.h" - -#include - -int main() -{ - Spel spel; - spel.setScore("Bert", 15); - std::cout << spel.getScore("Bert") << std::endl; // uikomst: 15 - Persoon *bert = spel.getPersoon("Bert"); - bert->setLeeftijd(103); - spel.addScore("Bert", 16); - std::cout << spel.getScore("Bert") << std::endl; // uikomst: 31 - bert = spel.getPersoon("Bert"); - std::cout << bert->getLeeftijd() << std::endl; // uikomst: 103 - spel.setScore("Joan", 512); - spel.setScore("Arthur", 1024); - for ( auto pair : spel.getScores() ) - { - std::cout << pair.first.getNaam() << "\t" - << pair.first.getLeeftijd() << "\t" - << pair.second << std::endl; - } - return 0; -} diff --git a/week-4/makefile b/week-4/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-4/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file diff --git a/week-5/StringWeek5.cpp b/week-5/StringWeek5.cpp deleted file mode 100644 index ae8ba9f..0000000 --- a/week-5/StringWeek5.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include "StringWeek5.h" - -void StringWeek5::removeAll(const std::string& remove) { - this->text = std::regex_replace(this->text, std::regex(remove), ""); -} - -const std::string& StringWeek5::getText() const { - return this->text; -} - diff --git a/week-5/StringWeek5.h b/week-5/StringWeek5.h deleted file mode 100644 index 8c2bdac..0000000 --- a/week-5/StringWeek5.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include - -class StringWeek5 { -public: - template - void add(const T& value); - void removeAll(const std::string& remove); - const std::string& getText() const; -private: - std::string text; -}; - -#include "StringWeek5.hpp" diff --git a/week-5/StringWeek5.hpp b/week-5/StringWeek5.hpp deleted file mode 100644 index ed71e75..0000000 --- a/week-5/StringWeek5.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "StringWeek5.h" -#include - -template -void StringWeek5::add(const T& value) { - std::stringstream value_str(""); - value_str << value; - this->text.append(value_str.str()); -} - diff --git a/week-5/main.cpp b/week-5/main.cpp deleted file mode 100644 index a2603fa..0000000 --- a/week-5/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "StringWeek5.h" - -#include - -int main() { - StringWeek5 myString; - - myString.add("hallo allemaal "); - myString.add(42); - myString.add(" "); - myString.add(3.14159265358979); - - std::cout << myString.getText() << std::endl; - - myString.removeAll("all"); - - std::cout << myString.getText() << std::endl << std::endl; - - return 0; -} diff --git a/week-5/makefile b/week-5/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-5/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file diff --git a/week-6/Punt.cpp b/week-6/Punt.cpp deleted file mode 100644 index 707047e..0000000 --- a/week-6/Punt.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "Punt.h" - -Punt::Punt() { - this->x = this->y = this->z = 0; -} - -Punt::Punt(int x, int y, int z) { - this->x = x; - this->y = y; - this->z = z; -} - -std::ostream& operator << ( std::ostream& output, const Punt& punt ) { - output << "(" << punt.x << "," << punt.y << "," << punt.z << ")"; - return output; -} - diff --git a/week-6/Punt.h b/week-6/Punt.h deleted file mode 100644 index b56e798..0000000 --- a/week-6/Punt.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -class Punt -{ -private: - Punt(); - Punt( int x, int y, int z ); - - friend std::ostream& operator << ( std::ostream& output, const Punt& punt ); - -private: - int x, y, z; - - friend class PuntContainer; -}; diff --git a/week-6/PuntContainer.cpp b/week-6/PuntContainer.cpp deleted file mode 100644 index e673472..0000000 --- a/week-6/PuntContainer.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include - -#include "PuntContainer.h" -#include "Punt.h" - -int PuntContainer::checkX(const Punt& punt1, const Punt& punt2) { - return punt1.x - punt2.x; -} - -int PuntContainer::checkY(const Punt& punt1, const Punt& punt2) { - return punt1.y - punt2.y; -} - -int PuntContainer::checkZ(const Punt& punt1, const Punt& punt2) { - return punt1.z - punt2.z; -} - -int PuntContainer::checkX2(const Punt& punt1, const Punt& punt2) const { - return punt1.x - punt2.x; -} - -int PuntContainer::checkY2(const Punt& punt1, const Punt& punt2) const { - return punt1.y - punt2.y; -} - -int PuntContainer::checkZ2(const Punt& punt1, const Punt& punt2) const { - return punt1.z - punt2.z; -} - -PuntContainer::PuntContainer() { - this->puntRij = (Punt*) malloc(sizeof(Punt) * 10); - this->grootte = 0; -} - -PuntContainer::~PuntContainer() { - free(this->puntRij); -} - -void PuntContainer::add(int x, int y, int z) { - puntRij[grootte].x = x; - puntRij[grootte].y = y; - puntRij[grootte].z = z; - grootte++; -} - -void PuntContainer::sort1(int (*fnCompare)(const Punt&, const Punt&)) { - for ( uint32_t outer = grootte-1; outer > 0; outer-- ) - for ( uint32_t inner=0; inner < outer; inner++ ) - if ( (*fnCompare)(puntRij[inner],puntRij[inner+1]) > 0 ) { - Punt temp = puntRij[inner]; - puntRij[inner] = puntRij[inner+1]; - puntRij[inner+1] = temp; - } -} - -void PuntContainer::sort2(int (PuntContainer::*fnCompare)(const Punt&, const Punt&) const) { - for ( uint32_t outer = grootte-1; outer > 0; outer-- ) - for ( uint32_t inner=0; inner < outer; inner++ ) { - if ( (*this.*fnCompare)(puntRij[inner],puntRij[inner+1]) > 0 ) { - Punt temp = puntRij[inner]; - puntRij[inner] = puntRij[inner+1]; - puntRij[inner+1] = temp; - } - } -} - -void PuntContainer::showAll() { - for (uint32_t i = 0; i < this->grootte; i++) - std::cout << this->puntRij[i] << std::endl; - std::cout << std::endl; -} - diff --git a/week-6/PuntContainer.h b/week-6/PuntContainer.h deleted file mode 100644 index 58c7875..0000000 --- a/week-6/PuntContainer.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -class Punt; - -#include - -class PuntContainer -{ -public: - PuntContainer(); - virtual ~PuntContainer(); - -public: - virtual void add( int x, int y, int z ); - - virtual void sort1( int (*)( const Punt&, const Punt&) ); - virtual void sort2( int (PuntContainer::*)( const Punt&, const Punt&) const ); - - virtual void showAll(); - -public: - static int checkX( const Punt& punt1, const Punt& punt2 ); - static int checkY( const Punt& punt1, const Punt& punt2 ); - static int checkZ( const Punt& punt1, const Punt& punt2 ); - -public: - virtual int checkX2( const Punt& punt1, const Punt& punt2 ) const; - virtual int checkY2( const Punt& punt1, const Punt& punt2 ) const; - virtual int checkZ2( const Punt& punt1, const Punt& punt2 ) const; - -private: - Punt* puntRij; - uint32_t grootte; -}; - diff --git a/week-6/main.cpp b/week-6/main.cpp deleted file mode 100644 index 701ac33..0000000 --- a/week-6/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "PuntContainer.h" - -#include - -int main() -{ - PuntContainer container; - - container.add( 1, 3, 4 ); - container.add( 3, 2, 1 ); - container.add( 2, 4, 2 ); - - container.sort2( &PuntContainer::checkZ2 ); - container.showAll(); - - container.sort2( &PuntContainer::checkY2 ); - container.showAll(); - - container.sort2( &PuntContainer::checkX2 ); - container.showAll(); - - return 0; -} diff --git a/week-6/makefile b/week-6/makefile deleted file mode 120000 index a4e84c6..0000000 --- a/week-6/makefile +++ /dev/null @@ -1 +0,0 @@ -../week.mk \ No newline at end of file -- cgit v1.2.3