This commit is contained in:
Arkadiusz Hypki 2024-11-22 10:59:03 +01:00
parent acdcd6feb9
commit 6751e98421
2 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,15 @@ string Human::getFirstname() {
} }
void Human::setFirstname(string firstname) { 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; this->firstname = firstname;
} }

View File

@ -22,6 +22,8 @@ int main() {
// cout << "pesel of employee" << e.getPesel(); // cout << "pesel of employee" << e.getPesel();
lib::Librarian l = lib::Librarian(); lib::Librarian l = lib::Librarian();
l.setFirstname("Arek");
cout << "First name: " << l.getFirstname() << endl;
l.setPesel(2000000000); l.setPesel(2000000000);
if (l.validate()) if (l.validate())
cout << "pesel of librarian" << l.getPesel(); cout << "pesel of librarian" << l.getPesel();