Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oleksenko Vladislav Platonov Denis Statistics University #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions human.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// human.h
#ifndef HUMAN_H_INCLUDED
#define HUMAN_H_INCLUDED

#include <string>
#include <sstream>

class human {
public:
// constructor human
human(std::string last_name,
std::string name)
{
this->last_name = last_name;
this->name = name;
}

// Get full name
std::string get_full_name()
{
std::ostringstream full_name;
full_name << this->last_name;
return full_name.str();
}

private:
std::string name; // ���
std::string last_name; // �������
};

#endif // HUMAN_H_INCLUDED
115 changes: 115 additions & 0 deletions project.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include <iostream>
#include <vector>
#include "worker.h"
#include "student.h"
#include "teacher.h"
#include "record_book.h"
int main(int argc, char* argv[])
{
std::vector<record_book> record_book_list;
std::vector<student> student_list;
std::vector<teacher> teacher_list;
std::vector<worker> worker_list;
std::string name, last_name, kind;
unsigned int experience, work_time,degree, basic_salary, record_book_num, number, mathematical_analysis, data_science, algebra, philosophy;
int N, num, j;
std::string mathematical_analysis_teacher, data_science_teacher, algebra_teacher, philosophy_teacher;
while (num != 8){
std::cout <<"Select operation mode: {1-8} "<<std::endl<<"1. Add a student"
<<std::endl<<"2. Add a teacher"<<std::endl<<"3. Add a record book"
<<std::endl<<"4. Operations with a teacher"<<std::endl<<"5. Operations with a student"<<std::endl<<"6. Add a worker "
<<std::endl<<"7. Show lists of people at the university"<<std::endl<<"8. Exit"<<std::endl;
std::cin>>num;
if (num == 1)
{
std::cout <<"Enter the student's last name, name, record book number"<<std::endl;
std::cin>> last_name;
std::cin>> name;
std::cin>> record_book_num;
student_list.push_back(student(last_name, name, record_book_num));
}
else if(num == 2){
std::cout <<"Enter the teacher's last name, name, experience, degree, work time in a week and basic salary at the university"<<std::endl;
std::cin>> last_name;
std::cin>> name;
std::cin>> experience;
std::cin>>degree;
std::cin>> work_time;
std::cin>> basic_salary;
teacher_list.push_back(teacher(last_name, name, experience,work_time,degree, basic_salary));
}
else if (num == 3){
std::cout <<"Enter record book: number, mathematical_analysis and teacher, data_science and teacher, algebra and teacher, philosophy and teacher: "<<std::endl;
std::cin>> number;
std::cin>> mathematical_analysis;
std::cin>> mathematical_analysis_teacher;
std::cin>> data_science;
std::cin>> data_science_teacher;
std::cin>> algebra;
std::cin>> algebra_teacher;
std::cin>> philosophy;
std::cin>> philosophy_teacher;
record_book_list.push_back(record_book(number, mathematical_analysis, mathematical_analysis_teacher, data_science,
data_science_teacher, algebra, algebra_teacher, philosophy, philosophy_teacher ));
}
else if (num == 4){
std::string tname;
std::cout<<"Enter the teacher name "<<std::endl;
std::cin>>tname;
for (int h = 0; h<teacher_list.size(); h++){
std::cout<<teacher_list[h].get_full_name();
if (tname == (teacher_list[h].get_full_name())){
std::cout<<"Salary: "<<teacher_list[h].get_salary()<<std::endl;
break;
}
std::cout<<"Teacher is not found "<<std::endl;
}
}
else if (num == 5){
std::string sname;
std::cout<<"Enter the student name "<<std::endl;
std::cin>>sname;
for (int h = 0; h<student_list.size(); h++){
if (sname == (student_list[h].get_full_name())){
for (int g = 0; h<record_book_list.size(); g++){
if (student_list[h].get_record_book_number() == record_book_list[g].get_number())
std::cout<<sname<<"'s average score is "<<record_book_list[g].get_average_score()<<std::endl;
break;
}
std::cout<<"Student or his record book is not found"<<std::endl;

}
}
}
else if (num == 6){
std::cout <<"Enter the worker's last name, name, kind of prof, experience, work time in a week and basic salary at the university"<<std::endl;
std::cin>> last_name;
std::cin>> name;
std::cin>> kind;
std::cin>> experience;
std::cin>> work_time;
std::cin>> basic_salary;
worker_list.push_back(worker(last_name, name, kind, experience,work_time, basic_salary));
}
else if (num == 7){
std::cout<<"Students: "<<std::endl;
for (int b = 0; b<student_list.size(); b++){
std::cout<<b<<"."<<student_list[b].get_full_name()<<std::endl;
}
std::cout<<"Teachers: "<<std::endl;
for (int b = 0; b<teacher_list.size(); b++){
std::cout<<b<<"."<<teacher_list[b].get_full_name()<<std::endl;
std::cout<<"Workers: "<<std::endl;
}
for (int b = 0; b<worker_list.size(); b++){
std::cout<<b<<"."<<worker_list[b].get_full_name()<<std::endl;
}
std::cout<<"Record books numbers: "<<std::endl;
for (int b = 0; b<record_book_list.size(); b++){
std::cout<<b<<"."<<record_book_list[b].get_number()<<std::endl;
}
}

}
return 0;
}
71 changes: 71 additions & 0 deletions record_book.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// record_book.h
#ifndef RECORD_BOOK_H_INCLUDED
#define RECORD_BOOK_H_INCLUDED

#include <string>
#include <sstream>

class record_book{
private:
unsigned int number;
unsigned int mathematical_analysis;
std::string mathematical_analysis_teacher;
unsigned int data_science;
std::string data_science_teacher;
unsigned int algebra;
std::string algebra_teacher;
unsigned int philosophy;
std::string philosophy_teacher;
public:
record_book(unsigned int number,
unsigned int mathematical_analysis, std::string mathematical_analysis_teacher,
unsigned int data_science, std::string data_science_teacher,
unsigned int algebra, std::string algebra_teacher,
unsigned int philosophy, std::string philosophy_teacher)
{
this->number = number;
this->mathematical_analysis = mathematical_analysis;
this->data_science = data_science;
this->algebra = algebra;
this->philosophy = philosophy;
this->mathematical_analysis_teacher = mathematical_analysis_teacher;
this->data_science_teacher = data_science_teacher;
this->algebra_teacher = algebra_teacher;
this->philosophy_teacher = philosophy_teacher;
}

unsigned int get_number()
{
return this->number;
}
// Get student's average score
float get_average_score()
{
std::vector<unsigned int> scores;
scores.push_back(this->mathematical_analysis);
scores.push_back(this->data_science);
scores.push_back(this->algebra);
scores.push_back(this->philosophy);
unsigned int sum_scores = 0;
// Average marks
float average_score;

for (unsigned int i = 0; i < 4; ++i) {
sum_scores += scores[i];
}

average_score = (float) sum_scores / 4.0;
return average_score;
}
std::vector<std::string> get_list_of_teachers()
{
std::vector<std::string> list_of_teachers;
list_of_teachers.push_back(this->mathematical_analysis_teacher);
list_of_teachers.push_back(this->data_science_teacher);
list_of_teachers.push_back(this->algebra_teacher);
list_of_teachers.push_back(this->philosophy_teacher);
return list_of_teachers;

}
};
#endif // RECORD_BOOK_H_INCLUDED
29 changes: 29 additions & 0 deletions student.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// student.h
#ifndef STUDENT_H_INCLUDED
#define STUDENT_H_INCLUDED

#include "human.h"
#include <string>
#include <vector>

class student : public human {
public:
// Student constructor
student(
std::string last_name,
std::string name,
unsigned int record_book_number
) : human(
last_name,
name
) {
this->record_book_number = record_book_number;
}
unsigned int get_record_book_number(){
return this->record_book_number;
}

private:
unsigned int record_book_number;
};
#endif // STUDENT_H_INCLUDED
67 changes: 67 additions & 0 deletions teacher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// teacher.h
#ifndef TEACHER_H_INCLUDED
#define TEACHER_H_INCLUDED

#include "human.h"
#include <string>

class teacher : public human {
// teacher constructor
public:
teacher(
std::string last_name,
std::string name,
// Work time and work experience
unsigned int experience,
unsigned int work_time,
unsigned int degree,
unsigned int basic_salary
) : human(
last_name,
name)
{
this->work_time = work_time;
this->experience = experience;
this->degree = degree;
this->basic_salary = basic_salary;
}

// Gettimg work time
unsigned int get_work_time()
{
return this->work_time;
}

// Gettimg an experience
unsigned int get_experience()
{
return this->experience;
}

// Gettimg an degree
unsigned int get_degree()
{
return this->degree;
}

// Gettimg a basic salary
unsigned int get_basic_salary()
{
return this->basic_salary;
}

float get_salary()
{
float salary = ((float) this->basic_salary * (2 - ((float) this ->degree * 0.1)) +
((float) this->basic_salary * (float)this ->experience * 0.1)) * (((float)this -> work_time)/40);
return salary;
}
private:
// Work time, experience, degree
unsigned int work_time;
unsigned int experience;
unsigned int degree;
unsigned int basic_salary;
};

#endif // TEACHER_H_INCLUDED
59 changes: 59 additions & 0 deletions worker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// worker.h
#ifndef WORKER_H_INCLUDED
#define WORKER_H_INCLUDED

#include "human.h"

class worker : public human {
// worker constructor
public:
worker(
std::string last_name,
std::string name,
std::string kind_of_prof,
// Work time and work experience
unsigned int experience,
unsigned int work_time,
unsigned int basic_salary
) : human(
last_name,
name)
{
this->work_time = work_time;
this->experience = experience;
this->basic_salary = basic_salary;
}

// Gettimg work time
unsigned int get_work_time()
{
return this->work_time;
}

// Gettimg an experience
unsigned int get_experience()
{
return this->experience;
}


// Gettimg a basic salary
unsigned int get_basic_salary()
{
return this->basic_salary;
}

float get_salary()
{
float salary = ((float) this->basic_salary * (2 - ((float) this ->degree * 0.1)) +
((float) this->basic_salary * (float)this ->experience * 0.1)) * (((float)this -> work_time)/40);
return salary;
}
private:
// Work time, experience, degree
unsigned int work_time;
unsigned int experience;
unsigned int degree;
unsigned int basic_salary;
};
#endif