diff --git a/include/Database.hpp b/include/Database.hpp index 937e3d2..9cc3f2e 100644 --- a/include/Database.hpp +++ b/include/Database.hpp @@ -25,8 +25,7 @@ class Database { void loadFromFile(std::string filename); std::vector changeString(std::string line); void createPersonIn(std::vector data); - - + void modifyAddress(const unsigned long int pesel, std::string newAddress); private: PeopleBase peopleBase_; }; diff --git a/include/Student.hpp b/include/Student.hpp index 37660a3..9bbe544 100644 --- a/include/Student.hpp +++ b/include/Student.hpp @@ -1,4 +1,3 @@ -#pragma once #include "../include/Person.hpp" #include diff --git a/src/Database.cpp b/src/Database.cpp index 8510061..df97610 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -37,7 +37,11 @@ void Database::sortByPesel() void Database::sortBySalary() { - +} +void Database::modifyAddress(const int pesel, const std::string newAddress) +{ + auto person = findByPesel(pesel); + person->setAddress(newAddress); } void Database::saveToFile(std::string filename) const diff --git a/src/main.cpp b/src/main.cpp index 1a83ab2..473e052 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,10 @@ int main() std::cout<<"Find By Pesel"; Person* ptr= db.findByPesel(10987654321); std::cout << ptr->getPersonDetails(); + + db.modifyAddress(87112345697, "Grabiszynska 9, 53-501 Wrocław"); + db.showBase(); + delete john; delete ben; return 0;