'Added some classes to the library project;'
This commit is contained in:
parent
657ffa4dfe
commit
2dc167c4fe
31
ex5-library/src/Employee.cpp
Normal file
31
ex5-library/src/Employee.cpp
Normal file
@ -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 */
|
26
ex5-library/src/Employee.h
Normal file
26
ex5-library/src/Employee.h
Normal file
@ -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_ */
|
45
ex5-library/src/Human.cpp
Normal file
45
ex5-library/src/Human.cpp
Normal file
@ -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 */
|
44
ex5-library/src/Human.h
Normal file
44
ex5-library/src/Human.h
Normal file
@ -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_ */
|
33
ex5-library/src/Librarian.cpp
Normal file
33
ex5-library/src/Librarian.cpp
Normal file
@ -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 */
|
25
ex5-library/src/Librarian.h
Normal file
25
ex5-library/src/Librarian.h
Normal file
@ -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_ */
|
24
ex5-library/src/main.cpp
Normal file
24
ex5-library/src/main.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//============================================================================
|
||||
// Name : wmi-bioinf-library.cpp
|
||||
// Author :
|
||||
// Version :
|
||||
// Copyright : Your copyright notice
|
||||
// Description : Hello World in C++, Ansi-style
|
||||
//============================================================================
|
||||
|
||||
#include <iostream>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user