diff options
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; +} |