diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-11-09 11:48:12 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-11-09 11:48:12 +0100 |
commit | ffae2cb77bfb3263146a2de0deedf6528d4df461 (patch) | |
tree | 88e4b61087069f8ce5badadbc6264d20b8a051d5 /week-4 | |
parent | d797758769d033c64babdf77ea6b64262f792b23 (diff) |
repository aanpassen voor oop2
Diffstat (limited to 'week-4')
-rw-r--r-- | week-4/Persoon.cpp | 22 | ||||
-rw-r--r-- | week-4/Persoon.h | 16 | ||||
-rw-r--r-- | week-4/Spel.cpp | 29 | ||||
-rw-r--r-- | week-4/Spel.h | 18 | ||||
-rw-r--r-- | week-4/main.cpp | 26 | ||||
l--------- | week-4/makefile | 1 |
6 files changed, 0 insertions, 112 deletions
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 <string> - -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<Persoon*>(&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<Persoon,int>& 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 <string> -#include <map> - -#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<Persoon,int>& getScores(); - - private: - std::map<Persoon, int> 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 <iostream>
-
-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 |