From 6751e98421308a28456234173a81a81858ad5d79 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Fri, 22 Nov 2024 10:59:03 +0100 Subject: [PATCH] 'Backup' --- ex5-library/src/Human.cpp | 9 +++++++++ ex5-library/src/main.cpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/ex5-library/src/Human.cpp b/ex5-library/src/Human.cpp index 7bf448e..3bb0ca5 100644 --- a/ex5-library/src/Human.cpp +++ b/ex5-library/src/Human.cpp @@ -31,6 +31,15 @@ string Human::getFirstname() { } void Human::setFirstname(string firstname) { + if (firstname.length() <= 0) { + cout << "First name is empty" << endl; + return; + } + if (firstname.find("_", 0) >= 0 + && firstname.find("_", 0) < 10000000000) { + cout << "First name contains illegal character _" << endl; + return; + } this->firstname = firstname; } diff --git a/ex5-library/src/main.cpp b/ex5-library/src/main.cpp index c80ec40..5559a99 100644 --- a/ex5-library/src/main.cpp +++ b/ex5-library/src/main.cpp @@ -22,6 +22,8 @@ int main() { // cout << "pesel of employee" << e.getPesel(); lib::Librarian l = lib::Librarian(); + l.setFirstname("Arek"); + cout << "First name: " << l.getFirstname() << endl; l.setPesel(2000000000); if (l.validate()) cout << "pesel of librarian" << l.getPesel();