diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-02-14 18:30:33 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-02-14 18:30:33 +0100 |
commit | 2bb7c5e97111c7c92dbf682ef49c54a229dfcfce (patch) | |
tree | 41ea601fd2e4b5fd136ce3f946672da4117919c0 /algo1w3/NAW.cpp | |
parent | d50c5a1af8be6ae51fec28e8b24dfea5ca591906 (diff) |
week 3 deel 1
Diffstat (limited to 'algo1w3/NAW.cpp')
-rw-r--r-- | algo1w3/NAW.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/algo1w3/NAW.cpp b/algo1w3/NAW.cpp new file mode 100644 index 0000000..907ad21 --- /dev/null +++ b/algo1w3/NAW.cpp @@ -0,0 +1,42 @@ +#include "NAW.h" +#include <iostream> + +NAW::NAW() { } + +NAW::NAW(const std::string& naam, const std::string& adres, const std::string& woonplaats) { + setNaam(naam); + setAdres(adres); + setPlaats(woonplaats); +} + +NAW::~NAW() { } + +int NAW::compareTo(const NAW& other) const { + int c; + c = getPlaats().compare(other.getPlaats()); + if (c != 0) return c; + c = getNaam().compare(other.getNaam()); + if (c != 0) return c; + c = getAdres().compare(other.getAdres()); + return c; +} + +const std::string& NAW::getNaam() const { return _naam; } +const std::string& NAW::getAdres() const { return _adres; } +const std::string& NAW::getPlaats() const { return _woonplaats; } + +void NAW::setNaam(const std::string& naam) { _naam = naam; } +void NAW::setAdres(const std::string& adres) { _adres = adres; } +void NAW::setPlaats(const std::string& woonplaats) { _woonplaats = woonplaats; } + +bool NAW::heeftNaam(const std::string& naam) const { return getNaam().compare(naam) == 0; } +bool NAW::heeftAdres(const std::string& adres) const { return getAdres().compare(adres) == 0; } +bool NAW::heeftPlaats(const std::string& woonplaats) const { return getPlaats().compare(woonplaats) == 0; } + +std::ostream& operator << (std::ostream& output, const NAW& naw) { + output << + "naam: " << naw.getNaam() << std::endl << + "adres: " << naw.getAdres() << std::endl << + "plaats: " << naw.getPlaats() << std::endl; + return output; +} |