Skip to content

Instantly share code, notes, and snippets.

@bilinin
Last active February 28, 2017 17:58
Show Gist options
  • Save bilinin/ad7ecba6f4ad070d23fe58f44452510e to your computer and use it in GitHub Desktop.
Save bilinin/ad7ecba6f4ad070d23fe58f44452510e to your computer and use it in GitHub Desktop.
student
#include <iostream>
#include <vector>
using namespace std;
struct date{
int day;
int month;
int year;
};
class Student{
public:
// Конструктор
Student(string FirstName, string LastName, string MiddleName, date Date, string Phone,string Adress, string Faculty, int Course){
set_first_name(FirstName);
set_last_name(LastName);
set_middle_name(MiddleName);
set_date(Date);
set_phone(Phone);
set_faculty(Faculty);
set_course(Course);
set_adress(Adress);
}
// Сеттеры
void set_first_name(string first_name){
FirstName = first_name;
}
void set_last_name(string last_name){
LastName = last_name;
}
void set_middle_name(string middle_name){
MiddleName = middle_name;
}
void set_date(date date){
Date = date;
}
void set_phone(string phone){
Phone = phone;
}
void set_faculty(string faculty){
Faculty = faculty ;
}
void set_course(int course){
Course = course ;
}
void set_adress(string adress){
Adress = adress ;
}
// Геттеры
string get_first_name(){
return FirstName;
}
string get_last_name(){
return LastName;
}
string get_middle_name(){
return MiddleName;
}
string get_phone(){
return Phone;
}
string get_faculty(){
return Faculty;
}
int get_course(){
return Course;
}
string get_adress(){
return Adress;
}
date get_date(){
return Date;
}
// other
void print_all_data(){
cout << FirstName << " " << LastName << " " << MiddleName << " "
<< Date.year << " " << Adress << " " << Phone << " " << Faculty << " " << Course << endl;
}
private:
string FirstName,
LastName,
MiddleName,
Adress,
Phone,
Faculty;
date Date;
int Course;
};
void search_faculty(vector <Student> Students, string Faculty ){
cout << "Students on "<< Faculty <<": \n";
int size = Students.size();
for(int i=0;i<size;i++){
if (Students[i].get_faculty() == Faculty){
Students[i].print_all_data();
}
}
}
void search_faculty_course(vector <Student> Students, string Faculty, int course){
cout << "\n\nStudents on "<< Faculty << " on " << course << " course: \n";
int size = Students.size();
for(int i=0;i<size;i++){
if ((Students[i].get_faculty() == Faculty) && (Students[i].get_course() == course)){
Students[i].print_all_data();
}
}
}
void list_faculty(vector <Student> Students){
for (int i = 1; i<4; i++){
search_faculty_course(Students, "AES",i);
search_faculty_course(Students, "IVT",i);
}
}
void search_year_more(vector <Student> Students, int Year ){
cout << "\n\nYear more " << Year <<": \n";
int size = Students.size();
for(int i=0;i<size;i++){
if (Students[i].get_date().year > Year){
Students[i].print_all_data();
}
}
}
int main() {
vector <Student> Students;
Students.push_back(Student("Ivan","Ivanov","Ivanovich",{1,10,1993},"89997776655","Kropotkina 10","AES",1));
Students.push_back(Student("Petr","Petrov","Petrovich",{1,10,1991},"89997776656","Kropotkina 20","IVT",2));
Students.push_back(Student("Andrey","Pushkin","Ivanovich",{1,10,1994},"89997776657","Kropotkina 21","IVT",3));
Students.push_back(Student("Oleg","Kalinin","Vladimirovich",{1,10,1991},"89997776658","Titova 23","AES",1));
Students.push_back(Student("Regina","Makarova","Daniilovna",{1,10,1995},"89997776659","Titova 23","IVT",2));
Students.push_back(Student("Evgeny","Abramov","Pavlovich",{1,10,1991},"89997776610","Dekabristov 7","AES",3));
Students.push_back(Student("Vladimir","Maksimov","Andreevich",{1,10,1993},"89997776611","Lenina 5","IVT",1));
Students.push_back(Student("Oksna","Muhina","Artemovna",{1,10,1991},"899977766512","Bogatkova 63","IVT",1));
search_faculty(Students, "IVT");
list_faculty(Students);
search_year_more(Students, 1992);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment