Skip to content

Commit c5454df

Browse files
committed
Dodalam metode modyfikujaca adres po nr PESEL
1 parent 0aa2db8 commit c5454df

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

include/Database.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Database {
1919
void sortByPesel();
2020
void saveToFile(std::string filename) const;
2121
void loadFromFile(std::string filename);
22+
void modifyAddress(const std::string pesel, const std::string newAddress);
2223

2324
private:
2425
PeopleBase peopleBase_;

include/Student.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#pragma once
21
#include "../include/Person.hpp"
32

43
class Student : public Person {

src/Database.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ void Database::sortByPesel()
3333
return lh->getPesel() < rh->getPesel();
3434
});
3535
}
36+
37+
void Database::modifyAddress(const std::string pesel, const std::string newAddress)
38+
{
39+
auto person = findByPesel(pesel);
40+
person->setAddress(newAddress);
41+
}
42+
3643
void Database::saveToFile(std::string filename) const
3744
{
3845
}

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ int main()
2525
db.sortByPesel();
2626
std::cout<<" \t---\n";
2727
db.showBase();
28+
29+
db.modifyAddress("87112345697", "Grabiszynska 9, 53-501 Wrocław");
30+
db.show("after modifyAddress");
31+
2832
delete john;
2933
delete ben;
3034
return 0;

0 commit comments

Comments
 (0)