Skip to content

Instantly share code, notes, and snippets.

@bilinin
Last active February 28, 2017 15:27
Show Gist options
  • Save bilinin/21f816e74c6600a8452b391b22209852 to your computer and use it in GitHub Desktop.
Save bilinin/21f816e74c6600a8452b391b22209852 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
class Worker{
public:
// Конструктор
Worker(string LastName, string Initials, string Post, int Year, int Pay){
set_last_name(LastName);
set_initials(Initials);
set_post(Post);
set_year(Year);
set_pay(Pay);
}
// Сеттеры
void set_last_name(string last_name){
LastName = last_name;
}
void set_initials(string initials){
Initials = initials;
}
void set_post(string post){
Post = post;
}
void set_year(int year){
Year = year;
}
void set_pay(int pay){
Pay = pay;
}
// Геттеры
string get_last_name(){
return LastName;
}
string get_initial(){
return Initials;
}
string get_post(){
return Post;
}
int get_year(){
return Year;
}
int get_pay(){
return Pay;
}
// other
void print_all_data(){
cout << LastName << " " << Initials << " " << Post << " "
<< " " << Year << " " << Pay << endl;
}
private:
string LastName,
Initials,
Post;
int Year,
Pay;
};
void show_stage_more(vector <Worker> Workers, int stage, int current_year){
int year = current_year - stage ;
cout << "\n\nStage more then " << stage << endl;
int size = Workers.size();
for (int i = 0;i<size; i++){
if(Workers[i].get_year() < year){
Workers[i].print_all_data();
}
}
}
void show_pay_more(vector <Worker> Workers, int pay){
cout << "\n\nPay more then " << pay << endl;
int size = Workers.size();
for (int i = 0;i<size; i++){
if(Workers[i].get_pay() > pay){
Workers[i].print_all_data();
}
}
}
void show_post(vector <Worker> Workers, string post){
cout << "\n\nWorkers on post: " << post << endl;
int size = Workers.size();
for (int i = 0;i<size; i++){
if(Workers[i].get_post() == post){
Workers[i].print_all_data();
}
}
}
int main() {
vector <Worker> Workers;
Workers.push_back(Worker("Ivanov","I.I","programmer",2000,15000));
Workers.push_back(Worker("Petrov","P.P","designer",2010,20000));
Workers.push_back(Worker("Pushkin","A.I","engineer",2004,25000));
Workers.push_back(Worker("Kalinin","O.V","programmer",2000,35000));
Workers.push_back(Worker("Makarova","R.D","engineer",2016,15000));
Workers.push_back(Worker("Abramov","E.P","engineer",2005,20000));
Workers.push_back(Worker("Maksimov","V.A","programmer",2011,40000));
Workers.push_back(Worker("Muhina","O.A","engineer",2007,42000));
show_stage_more(Workers, 5, 2017);
show_pay_more(Workers, 15000);
show_post(Workers, "engineer");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment