diff --git a/ex5-library/src/Employee.cpp b/ex5-library/src/Employee.cpp new file mode 100644 index 0000000..f1a7707 --- /dev/null +++ b/ex5-library/src/Employee.cpp @@ -0,0 +1,31 @@ +/* + * Employee.cpp + * + * Created on: Nov 15, 2024 + * Author: ahypki + */ + +#include "Employee.h" + +namespace lib { + +Employee::Employee() { + // TODO Auto-generated constructor stub + +} + +Employee::Employee(int pesel) { + setPesel(pesel); +} + +Employee::~Employee() { + // TODO Auto-generated destructor stub +} + +bool Employee::validate() { + if (getPesel() < 1000000) + return false; + return true; +} + +} /* namespace lib */ diff --git a/ex5-library/src/Employee.h b/ex5-library/src/Employee.h new file mode 100644 index 0000000..b707eb9 --- /dev/null +++ b/ex5-library/src/Employee.h @@ -0,0 +1,26 @@ +/* + * Employee.h + * + * Created on: Nov 15, 2024 + * Author: ahypki + */ + +#ifndef EMPLOYEE_H_ +#define EMPLOYEE_H_ + +#include "Human.h" + +namespace lib { + +class Employee : public Human { +public: + Employee(); + Employee(int pesel); + ~Employee(); + + bool validate(); +}; + +} /* namespace lib */ + +#endif /* EMPLOYEE_H_ */ diff --git a/ex5-library/src/Human.cpp b/ex5-library/src/Human.cpp new file mode 100644 index 0000000..7bf448e --- /dev/null +++ b/ex5-library/src/Human.cpp @@ -0,0 +1,45 @@ +/* + * Human.cpp + * + * Created on: Nov 15, 2024 + * Author: ahypki + */ + +#include "Human.h" + +namespace lib { + +Human::Human() { + // TODO Auto-generated constructor stub + +} + +Human::~Human() { + // TODO Auto-generated destructor stub +} + +long Human::getPesel() { + return pesel; +} + +void Human::setPesel(long pesel) { + this->pesel = pesel; +} + +string Human::getFirstname() { + return this->firstname; +} + +void Human::setFirstname(string firstname) { + this->firstname = firstname; +} + +string Human::getPosition() { + return this->position; +} + +void Human::setPosition(string position) { + this->position = position; +} + +} /* namespace lib */ diff --git a/ex5-library/src/Human.h b/ex5-library/src/Human.h new file mode 100644 index 0000000..d005be4 --- /dev/null +++ b/ex5-library/src/Human.h @@ -0,0 +1,44 @@ +/* + * Human.h + * + * Created on: Nov 15, 2024 + * Author: ahypki + */ + +#ifndef HUMAN_H_ +#define HUMAN_H_ + +#include "iostream" + +namespace lib { + +using namespace std; + +class Human { +private: + long pesel = 1234; + string firstname; + string lastname; + string position; +protected: + virtual bool validate() = 0; +public: + Human(); + virtual ~Human(); + + long getPesel(); + void setPesel(long pesel); + + string getFirstname(); + void setFirstname(string firstname); + + string getLastname(); + void setLastname(string lastname); + + string getPosition(); + void setPosition(string position); +}; + +} /* namespace lib */ + +#endif /* HUMAN_H_ */ diff --git a/ex5-library/src/Librarian.cpp b/ex5-library/src/Librarian.cpp new file mode 100644 index 0000000..4f99f1f --- /dev/null +++ b/ex5-library/src/Librarian.cpp @@ -0,0 +1,33 @@ +/* + * Librarian.cpp + * + * Created on: Nov 22, 2024 + * Author: ahypki + */ + +#include "Librarian.h" + +namespace lib { + +Librarian::Librarian() { + // TODO Auto-generated constructor stub + +} + +Librarian::~Librarian() { + // TODO Auto-generated destructor stub +} + +bool Librarian::validate() { + bool fromParent = Employee::validate(); + if (fromParent == false) + return false; + + // additional checks + if (getPosition().compare("librarian") != 0) + return false; + + return true; +} + +} /* namespace lib */ diff --git a/ex5-library/src/Librarian.h b/ex5-library/src/Librarian.h new file mode 100644 index 0000000..f84fbc1 --- /dev/null +++ b/ex5-library/src/Librarian.h @@ -0,0 +1,25 @@ +/* + * Librarian.h + * + * Created on: Nov 22, 2024 + * Author: ahypki + */ + +#ifndef LIBRARIAN_H_ +#define LIBRARIAN_H_ + +#include "Employee.h" + +namespace lib { + +class Librarian : public Employee { +public: + Librarian(); + virtual ~Librarian(); + + bool validate(); +}; + +} /* namespace lib */ + +#endif /* LIBRARIAN_H_ */ diff --git a/ex5-library/src/main.cpp b/ex5-library/src/main.cpp new file mode 100644 index 0000000..44a56b0 --- /dev/null +++ b/ex5-library/src/main.cpp @@ -0,0 +1,24 @@ +//============================================================================ +// Name : wmi-bioinf-library.cpp +// Author : +// Version : +// Copyright : Your copyright notice +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include +#include "Human.h" +#include "Employee.h" + +using namespace std; + +int main() { + std::cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! + + lib::Employee e = lib::Employee(); + + if (e.validate()) + cout << "pesel of employee" << e.getPesel(); + + return 0; +}