Кабінет 208
Головна | Реєстрація | Вхід
Вівторок, 22.01.2019, 23:00
Меню сайту
Форма входу

Категорії розділу
5 клас [11]
6 клас [5]
7 клас [3]
8 клас [15]
9 клас [19]
10 клас (стардарт) [5]
10 клас (академічний) [0]
11 клас (стандарт) [21]
11 клас (академічний) [23]
Головна » Статті » Інформатика » 11 клас (академічний)

Класи в С++ (третя)

// ver 3.cpp: определяет точку входа для консольного приложения.
#include "stdafx.h"
#include"conio.h"
#include"iostream"
#include"string"
#include "Employee.h"
#include "University.h"
#include "Student.h"
#include "Company.h"
#include"Ministry.h"
#include"Professor.h"
#include"Project.h"
#include <vector>
using namespace std;

#define _Line cout <<    "________________________________________________________________________________________________________" << "\n\n"
#define Tab_Line cout << "========================================================================================================" << "\n"

void main()
{
    Tab_Line;
    cout << "????" << endl;
    cout << "Version 3\n" << endl;
    //cout << "Start modeling\n" << endl;
    cout << "You can create Network and start modeling of system: Project(University(Professor, Student), Ministry, Company(Employee))\n";
    cout << "Please, make your choice:\n 1. Start modeling\n 2.Exit\n\n";
    Tab_Line;
    int a;
    cin >> a;
    switch (a)
    {
    case 1:
    {
              _Line;
              cout << "\n\nCreating 'Project'\n\n";
              _Line;
              Project pro1;//конструктор за замовчуванням
              std::string n;
              std::string d;
              int t;
              int numb;
              cout << "PROJECT\nSet Name: ";
              cin >> n; pro1.SetName(n);//встановити назву
              cout << "Set Project's description: ";
              cin >> d;  pro1.SetDescription(d);
              cout << "Set Project's term of execution(int): ";
              cin >> t;  pro1.SetTermOfExecution(t);
              cout << "Set Project's number of worker(int): ";
              cin >> numb;  pro1.SetNumberOfWorker(numb);
              cout << endl;
              _Line;
              cout << "Project\nName: " << pro1.GetName() << "\nProduct's description:" << pro1.GetDescription() << "\nProduct's term of execution:" << pro1.GetTermOfExecution() << "\nProduct's number of worker:" << pro1.GetNumberOfWorker() << endl;
              cout << endl;
              Tab_Line;
              pro1.add_company();
              pro1.add_ministry();
              pro1.add_university();
              break;
    }
    case 2:
    {
              break;
    }
    default:
        break;
    }
    cout << "\nFinish modeling\n\n" << endl;
    system("pause");
}


 * Module:  Project.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

#define _Line cout <<    "________________________________________________________________________________________________________" << "\n\n"
#define Tab_Line cout << "========================================================================================================" << "\n"

Project::Project()
:m_company(),
m_university(),
m_ministry(),
name(""),
description(""),
term_of_execution(0),
number_of_worker(0)
{
    cout << "Project was created (default)" << endl;
}

Project::Project(string n, string d, int t, int numb)
:name(n),
description(d),
term_of_execution(t),
number_of_worker(numb)
{
    cout << "Project was created (initialization)" << endl;
}

Project::Project(const Project& sProject)
:name(sProject.name),
description(sProject.description),
term_of_execution(sProject.term_of_execution),
number_of_worker(sProject.number_of_worker)
{
    cout << "Project was created (copy)" << endl;
}

Project::Project(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    description = str2;

    std::string str3 = str.substr(8, 4);
    const char* s3 = str3.c_str();
    term_of_execution = atoi(s3);

    std::string str4 = str.substr(12, 4);
    const char* s4 = str4.c_str();
    number_of_worker = atoi(s4);

    cout << "Project was created (transformation)." << endl;
} // конструктор перетворення


Project::~Project()
{
    cout << "Project was deleted" << endl;
}

 

std::string Project::GetName()
{
    return name;
}

void Project::SetName(std::string k)
{
    name = k;
}

std::string Project::GetDescription()
{
    return description;
}

void Project::SetDescription(std::string l)
{
    description = l;
}

int Project::GetTermOfExecution()
{
    return term_of_execution;
}

void Project::SetTermOfExecution(int o)
{
    term_of_execution = o;
}

int Project::GetNumberOfWorker()
{
    return number_of_worker;
}

void Project::SetNumberOfWorker(int t)
{
    number_of_worker = t;
}

void Project::add_company(void)
{
    cout << endl << "creating 'Company':\n" << endl;
    _Line;
    std::string n;
    int numb;
    std::string loc;
    std::string type;
    cout << "Input name of company: ";
    cin >> n; m_company.SetName(n);
    cout << "Input number of employees of company(int): ";
    cin >> numb; m_company.SetNumberOfEmployee(numb);
    cout << "Input location of company: ";
    cin >> loc; m_company.SetLocation(loc);
    cout << "Input type of employment of company: ";
    cin >> type; m_company.SetTypeOfEmployment(type);
    cout << endl;
    _Line;
    cout << "Company created:" << endl;
    cout << "Company\nName: " << m_company.GetName() << endl << "Number of employees: " << m_company.GetNumberOfEmployee() << endl << "Location: " << m_company.GetLocation() << endl << "Type of employment: " << m_company.GetTypeOfEmployment() << endl;
    cout << endl;
    Tab_Line;
    cin.get();
    m_company.add_employee();
}

void Project::add_ministry(void)
{
    cout << endl << "creating 'Ministry':\n" << endl;
    _Line;
    std::string name;
    int number_of_employee;
    int budget;
    cout << "Input name of ministry: ";
    cin >> name; m_ministry.SetName(name);
    cout << "Input number_of_employees of ministry(int): ";
    cin >> number_of_employee; m_ministry.SetNumberOfEmployee(number_of_employee);
    cout << "Input budget of ministry(int): ";
    cin >> budget; m_ministry.SetBudget(budget);
    cout << endl;
    _Line;
    cout << "Ministry created:" << endl;
    cout << "Ministry\nName: " << m_ministry.GetName() << endl << "Number of employees: " << m_ministry.GetNumberOfEmployee() << endl << "Budget: " << m_ministry.GetBudget() << endl;
    cout << endl;
    Tab_Line;
    cin.get();
}

void Project::add_university(void)
{
    cout << endl << "creating 'University':\n" << endl;
    _Line;
    std::string name;
    int number_of_students;
    int number_of_teachers;
    int number_of_faculties;
    cout << "Input name of university: ";
    cin >> name; m_university.SetName(name);
    cout << "Input number of students of university(int): ";
    cin >> number_of_students; m_university.SetNumberOfStudents(number_of_students);
    cout << "Input number of teachers of university(int): ";
    cin >> number_of_teachers; m_university.SetNumberOfTeachers(number_of_teachers);
    cout << "Input number_of_faculties of university(int): ";
    cin >> number_of_faculties; m_university.SetNumberOfFaculties(number_of_faculties);
    cout << endl;
    _Line;
    cout << "University created:" << endl;
    cout << "University\nName: " << m_university.GetName() << endl << "Number of students: " << m_university.GetNumberOfStudents() << endl << "Number of teachers: " << m_university.GetNumberOfTeachers() << endl << "Number of faculties: " << m_university.GetNumberOfFaculties() << endl;
    cout << endl;
    Tab_Line;
    cin.get();
    m_university.add_professor();
    m_university.add_student();
}

void Project::start(void)
{
   // TODO : implement
}

 * Module:  Project.h
#if !defined(__ClassDiagram_Project_h)
#define __ClassDiagram_Project_h

#include "stdafx.h"
#include "Company.h"
#include "University.h"
#include "Ministry.h"
#include<string>
#include<iostream>
#include <vector>
using namespace std;

class Company;
class University;
class Ministry;

 

class Project
{
protected:
private:
    Company m_company;
    University m_university;
    Ministry m_ministry;
    
   std::string name;
   std::string description;
   int term_of_execution;
   int number_of_worker;
 
public:
    Project();
    Project(string, string, int, int);
    Project(const Project&);
    Project(string);
    ~Project();

   void start(void);
   void add_company(void);
   void add_ministry(void);
   void add_university(void);
   std::string GetName();
   std::string GetDescription();
   int GetTermOfExecution();
   int GetNumberOfWorker();
   void SetName(std::string );
   void SetDescription(std::string );
   void SetTermOfExecution(int );
   void SetNumberOfWorker(int );


  /*Company** company;
   University** university;
   Ministry* ministry;
  */
};

#endif

 * Module:  Company.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

#define _Line cout <<    "________________________________________________________________________________________________________" << "\n\n"
#define Tab_Line cout << "========================================================================================================" << "\n"

Company::Company()
: m_employee(),
name(""),
number_of_employees(0),
location(""),
type_of_employment("")
{
    cout << "Company was created (default)" << endl;
}

Company::Company(string n, int numb, string l, string t)
:name(n),
number_of_employees(numb),
location(l),
type_of_employment(t)
{
    cout << "Company was created (initialization)" << endl;
}

Company::Company(const Company& sCompany)
:name(sCompany.name),
number_of_employees(sCompany.number_of_employees),
location(sCompany.location),
type_of_employment(sCompany.type_of_employment)
{
    cout << "Company was created (copy)" << endl;
}

Company::Company(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    number_of_employees = atoi(s2);

    std::string str3 = str.substr(8, 4);
    location = str3;

    std::string str4 = str.substr(12, 4);
    type_of_employment = str4;

    cout << "Company was created (transformation)." << endl;
} // конструктор перетворення

Company::~Company()
{
    cout << "Company was deleted" << endl;
}

std::string Company::GetName()
{
    return name;
}
void Company::SetName(std::string k)
{
    name = k;
}

int Company::GetNumberOfEmployee()
{
    return number_of_employees;
}

void Company::SetNumberOfEmployee(int m)
{
    number_of_employees = m;
}

std::string Company::GetLocation()
{
    return location;
}
void Company::SetLocation(std::string f)
{
    location = f;
}

std::string Company::GetTypeOfEmployment()
{
    return type_of_employment;
}
void Company::SetTypeOfEmployment(std::string e)
{
    type_of_employment = e;
}

void Company::add_employee(void)
{
    cout << endl << "creating 'Employee':\n" << endl;
    _Line;
    std::string name;
    int age;
    std::string work;
    int salary;

    cout << "Input name of employee: ";
    cin >> name; m_employee.SetName(name);
    cout << "Input age of employee(int): ";
    cin >> age; m_employee.SetAge(age);
    cout << "Input work of employee: ";
    cin >> work; m_employee.SetWork(work);
    cout << "Input salary of employee(int): ";
    cin >> salary; m_employee.SetSalary(salary);
    cout << endl;
    _Line;
    cout << "Employee created:" << endl;
    cout << "Employee\nName: " << m_employee.GetName() << endl << "Age: " << m_employee.GetAge() << endl << "Work: " << m_employee.GetWork() << endl << "Salary: " << m_employee.GetSalary() << endl;
    cout << endl;
    Tab_Line;
}

void Company::create_your_own_divisions(void)
{
    // TODO : implement
}

void Company::fund_university(void)
{
    // TODO : implement
}

void Company::give_projects(void)
{
    // TODO : implement
}

 * Module:  Company.h
#if !defined(__ClassDiagram_Company_h)
#define __ClassDiagram_Company_h
#include "stdafx.h"
#include "Employee.h"
#include<string>
#include<iostream>
#include<vector>
using namespace std;

class Employee;

class Company
{
protected:
private:
    Employee m_employee;

   std::string name;
   int number_of_employees;
   std::string location;
   std::string type_of_employment;
   
public:
    Company();
    Company(string, int, string, string);
    Company(const Company&);
    Company(string);
    ~Company();

   void add_employee(void);
   void create_your_own_divisions(void);
   void fund_university(void);
   void give_projects(void);
   std::string GetName(); // отримати ім'я
   int GetNumberOfEmployee(); // отримати кількість працівників
   std::string GetLocation();
   std::string GetTypeOfEmployment();
   void SetName(std::string); // встановити ім'я
   void SetNumberOfEmployee(int); // встановити кількість працівників
   void SetTypeOfEmployment(std::string);
   void SetLocation(std::string);

  // Employee** employee;

};

#endif


 * Module:  Employee.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

Employee::Employee()
:name(""),
age(0),
work(""),
salary(0)
{
    cout << "Employee was created (default)" << endl;
}

Employee::Employee(string n, int a, string w, int s)
:name(n),
age(a),
work(w),
salary(s)
{
    cout << "Employee was created (initialization)" << endl;
}

Employee::Employee(const Employee& sEmployee)
:name(sEmployee.name),
age(sEmployee.age),
work(sEmployee.work),
salary(sEmployee.salary)
{
    cout << "Employee was created (copy)" << endl;
}

Employee::Employee(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    age = atoi(s2);

    std::string str3 = str.substr(8, 4);
    work = str3;

    std::string str4 = str.substr(12, 4);
    const char* s4 = str4.c_str();
    salary = atoi(s4);

    cout << "Employee was created (transformation)." << endl;
} // конструктор перетворення

Employee::~Employee()
{
    cout << "Employee was deleted" << endl;
}


void Employee::give_project(void)
{
   // TODO : implement
}

void Employee::provide_resources(void)
{
   // TODO : implement
}

void Employee::keeps_track_implementation(void)
{
   // TODO : implement
}

void Employee::takes_job(void)
{
   // TODO : implement
}

std::string Employee::GetName()
{
    return name;
}
void Employee::SetName(std::string k)
{
    name = k;
}

int Employee::GetAge()
{
    return age;
}
void Employee::SetAge(int f)
{
    age = f;
}


std::string Employee::GetWork()
{
    return work;
}
void Employee::SetWork(std::string e)
{
    work = e;
}

int Employee::GetSalary()
{
    return salary;
}
void Employee::SetSalary(int p)
{
    salary = p;
}


 * Module:  Employee.h
#if !defined(__ClassDiagram_Employee_h)
#define __ClassDiagram_Employee_h
#include "stdafx.h"
#include<string>
#include<iostream>
using namespace std;

class Employee
{
protected:
private:
   std::string name;
   int age;
   std::string work;
   int salary;


public:
    Employee();
    Employee(string, int, string, int);
    Employee(const Employee&);
    Employee(string);
    ~Employee();

   void give_project(void);
   void provide_resources(void);
   void keeps_track_implementation(void);
   void takes_job(void);
   std::string GetName();
   int GetAge();
   std::string GetWork();
   int GetSalary();
   void SetName(std::string);
   void SetAge(int);
   void SetWork(std::string);
   void SetSalary(int);
};

#endif


 * Module:  Ministry.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

Ministry::Ministry()
:name(""),
number_of_employee(0),
budget(0)
{
    cout << "Ministry was created (default)" << endl;
}

Ministry::Ministry(string n, int numb, int b)
:name(n),
number_of_employee(numb),
budget(b)
{
    cout << "Ministry was created (initialization)" << endl;
}

Ministry::Ministry(const Ministry& sMinistry)
:name(sMinistry.name),
number_of_employee(sMinistry.number_of_employee),
budget(sMinistry.budget)
{
    cout << "Ministry was created (copy)" << endl;
}

Ministry::Ministry(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    number_of_employee = atoi(s2);

    std::string str3 = str.substr(8, 4);
    const char* s3 = str3.c_str();
    budget = atoi(s3);

    cout << "Ministry was created (transformation)." << endl;
} // конструктор перетворення

Ministry::~Ministry()
{
    cout << "Ministry was deleted" << endl;
}

void Ministry::set_framework_for_university(void)
{
   // TODO : implement
}

void Ministry::provide_staff(void)
{
   // TODO : implement
}

void Ministry::provide_necessary_resources(void)
{
   // TODO : implement
}

int Ministry::GetNumberOfEmployee()
{
    return number_of_employee;
}

int Ministry::GetBudget()
{
    return budget;
}

std::string Ministry::GetName()
{
    return name;
}
void Ministry::SetName(std::string k)
{
    name = k;
}

void Ministry::SetNumberOfEmployee(int m)
{
    number_of_employee = m;
}

void Ministry::SetBudget(int l)
{
    budget = l;
}


 * Module:  Ministry.h
#if !defined(__ClassDiagram_Ministry_h)
#define __ClassDiagram_Ministry_h
#include "stdafx.h"
#include<string>
#include<iostream>
using namespace std;
class Ministry
{
protected:
private:
   int number_of_employee;
   int budget;
   std::string name;

public:
    Ministry();
    Ministry(string, int, int);
    Ministry(const Ministry&);
    Ministry(string);
    ~Ministry();

   void set_framework_for_university(void);
   void provide_staff(void);
   void provide_necessary_resources(void);
   std::string GetName(); // отримати ім'я
   int GetNumberOfEmployee(); // отримати кількість працівників
   int GetBudget(); // отримати бюджет
   void SetName(std::string); // встановити ім'я
   void SetNumberOfEmployee(int); // встановити кількість працівників
   void SetBudget(int); // встановити бюджет

};

#endif


 * Module:  Professor.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

Professor::Professor():
name(""),
age(1),
work(""),
experience(1),
faculty("")
{
    cout << "Professor was created (default)" << endl;
}// конструктор за замовченням

Professor::Professor(string n, int a, string w, int e, string f):
name(n),
age(a),
work(w),
experience(e),
faculty(f)
{
    cout << "Professor was created (initialization)" << endl;
}// конструктор ініціалізації

Professor::Professor(const Professor& sProfessor):
name(sProfessor.name),
age(sProfessor.age),
work(sProfessor.work),
experience(sProfessor.experience),
faculty(sProfessor.faculty)
{
    cout << "Professor was created (copy)" << endl;
}// конструктор копії

Professor::Professor(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    age = atoi(s2);
    
    std::string str3 = str.substr(8, 4);
    work = str3;

    std::string str4 = str.substr(12, 4);
    const char* s4 = str4.c_str();
    experience = atoi(s4);

    std::string str5 = str.substr(16, 4);
    faculty = str5;

    cout << "Professor was created (transformation)." << endl;
} // конструктор перетворення

Professor::~Professor()
{
    cout << "Professor was deleted" << endl;
}

void Professor::teach_student(void)
{
   // TODO : implement
}

void Professor::work_on_the_project(void)
{
   // TODO : implement
}

void Professor::conduct_research(void)
{
   // TODO : implement
}

std::string Professor::GetName()
{
    return name;
}
void Professor::SetName(std::string k)
{
    name = k;
}

int Professor::GetAge()
{
    return age;
}
void Professor::SetAge(int l)
{
    age = l;
}


std::string Professor::GetWork()
{
    return work;
}
void Professor::SetWork(std::string p)
{
    work = p;
}

int Professor::GetExperience()
{
    return experience;
}
void Professor::SetExperience(int y)
{
    experience = y;
}

std::string Professor::GetFaculty()
{
    return faculty;
}
void Professor::SetFaculty(std::string o)
{
    faculty = o;
}


 * Module:  Professor.h
#if !defined(__ClassDiagram_Professor_h)
#define __ClassDiagram_Professor_h
#include "stdafx.h"
#include "Professor.h"
#include<string>
#include<iostream>
using namespace std;

class Professor
{
protected:
private:
   std::string name;
   int age;
   std::string work;
   int experience;
   std::string faculty;

public:
    Professor();
    Professor(string, int, string, int, string);
    Professor(const Professor&);
    Professor(string);
    ~Professor();

   void teach_student(void);
   void work_on_the_project(void);
   void conduct_research(void);
   std::string GetName();
   int GetAge();
   std::string GetWork();
   int GetExperience();
   std::string GetFaculty();
   void SetName(std::string);
   void SetAge(int);
   void SetWork(std::string);
   void SetExperience(int);
   void SetFaculty(std::string);
};

#endif


 * Module:  Student.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

Student::Student()
:name(""),
age(0),
group(""),
course(0),
faculty("")
{
    cout << "Student was created (default)" << endl;
}

Student::Student(string n, int a, string g, int c, string f)
:name(n),
age(a),
group(g),
course(c),
faculty(f)
{
    cout << "Student was created (initialization)" << endl;
}

Student::Student(const Student& sStudent)
:name(sStudent.name),
age(sStudent.age),
group(sStudent.group),
course(sStudent.course),
faculty(sStudent.faculty)
{
    cout << "Student was created (copy)" << endl;
}

Student::Student(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    age = atoi(s2);

    std::string str3 = str.substr(8, 4);
    group = str3;

    std::string str4 = str.substr(12, 4);
    const char* s4 = str4.c_str();
    course = atoi(s4);

    std::string str5 = str.substr(16, 4);
    faculty = str5;

    cout << "Student was created (transformation)." << endl;
} // конструктор перетворення


Student::~Student()
{
    cout << "Student was deleted" << endl;
}

void Student::study_at_univer(void)
{
   // TODO : implement
}

void Student::working_on_a_project(void)
{
   // TODO : implement
}

void Student::conducts_research(void)
{
   // TODO : implement
}

std::string Student::GetName()
{
    return name;
}
void Student::SetName(std::string k)
{
    name = k;
}

int Student::GetAge()
{
    return age;
}
void Student::SetAge(int l)
{
    age = l;
}

std::string Student::GetGroup()
{
    return group;
}
void Student::SetGroup(std::string o)
{
    group = o;
}

int Student::GetCourse()
{
    return course;
}
void Student::SetCourse(int l)
{
    course = l;
}

std::string Student::GetFaculty()
{
    return faculty;
}
void Student::SetFaculty(std::string o)
{
    faculty = o;
}


 * Module:  Student.h
#if !defined(__ClassDiagram_Student_h)
#define __ClassDiagram_Student_h

#include "stdafx.h"
#include<string>
#include<iostream>
using namespace std;

class Student
{
protected:
private:
   std::string name;
   int age;
   std::string faculty;
   int course;
   std::string group;

public:
    Student();
    Student(string, int, string, int, string);
    Student(const Student&);
    Student(string);
    ~Student();

   void study_at_univer(void);
   void working_on_a_project(void);
   void conducts_research(void);
   std::string GetName();
   int GetAge();
   std::string GetGroup();
   int GetCourse();
   std::string GetFaculty();
   void SetName(std::string);
   void SetAge(int);
   void SetGroup(std::string);
   void SetCourse(int);
   void SetFaculty(std::string);

};

#endif


 * Module:  University.cpp
#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include "University.h"
#include "Company.h"
#include "Employee.h"
#include "Ministry.h"
#include "Project.h"
#include<string>
#include<iostream>
using namespace std;

#define _Line cout <<    "________________________________________________________________________________________________________" << "\n\n"
#define Tab_Line cout << "========================================================================================================" << "\n"

University::University()
:m_professor(),
m_student(),
name(""),
number_of_students(0),
number_of_teachers(0),
number_of_faculties(0)
{
    cout << "University was created (default)" << endl;
}

University::University(string n, int ns, int nt, int nf)
:name(n),
number_of_students(ns),
number_of_teachers(nt),
number_of_faculties(nf)
{
    cout << "University was created (initialization)" << endl;
}

University::University(const University& sUniversity)
:name(sUniversity.name),
number_of_students(sUniversity.number_of_students),
number_of_teachers(sUniversity.number_of_teachers),
number_of_faculties(sUniversity.number_of_faculties)
{
    cout << "University was created (copy)" << endl;
}

University::University(std::string str){

    std::string str1 = str.substr(0, 4);
    name = str1;

    std::string str2 = str.substr(4, 4);
    const char* s2 = str2.c_str();
    number_of_students = atoi(s2);

    std::string str3 = str.substr(8, 4);
    const char* s3 = str3.c_str();
    number_of_teachers = atoi(s3);

    std::string str4 = str.substr(12, 4);
    const char* s4 = str4.c_str();
    number_of_faculties = atoi(s4);

    cout << "University was created (transformation)." << endl;
} // конструктор перетворення

University::~University()
{
    cout << "University was deleted" << endl;
}

 


std::string University::GetName()
{
    return name;
}
void University::SetName(std::string k)
{
    name = k;
}

int University::GetNumberOfStudents()
{
    return number_of_students;
}
void University::SetNumberOfStudents(int l)
{
    number_of_students = l;
}

int University::GetNumberOfTeachers()
{
    return number_of_teachers;
}
void University::SetNumberOfTeachers(int m)
{
    number_of_teachers = m;
}

int University::GetNumberOfFaculties()
{
    return number_of_faculties;
}
void University::SetNumberOfFaculties(int p)
{
    number_of_faculties = p;
}

void University::add_student(void)
{
    cout << endl << "creating 'Student':\n" << endl;
    _Line;
    std::string name;
    int age;
    std::string faculty;
    int course;
    std::string group;

    cout << "Input name of student: ";
    cin >> name; m_student.SetName(name);
    cout << "Input age of student(int): ";
    cin >> age; m_student.SetAge(age);
    cout << "Input faculty of student: ";
    cin >> faculty; m_student.SetFaculty(faculty);
    cout << "Input course of student(int): ";
    cin >> course;  m_student.SetCourse(course);
    cout << "Input group of student: ";
    cin >> group; m_student.SetGroup(group);
    cout << endl;
    _Line;
    cout << "Student created:" << endl;
    cout << "Student\nName: " << m_student.GetName() << "\nStudent's age:" << m_student.GetAge() << "\nStudent's faculty:" << m_student.GetFaculty() << "\nStudent's course:" << m_student.GetCourse() << "\nStudent's group:" << m_student.GetGroup() << endl;
    cout << endl;
    Tab_Line;
}

void University::add_professor(void)
{
    cout << endl << "creating 'Professor':\n" << endl;
    _Line;
    std::string name;
    int age;
    std::string work;
    int experience;
    std::string faculty;

    cout << "Input name of professor: ";
    cin >> name; m_professor.SetName(name);
    cout << "Input age of professor(int): ";
    cin >> age; m_professor.SetAge(age);
    cout << "Input work of professor: ";
    cin >> work; m_professor.SetWork(work);
    cout << "Input experience of professor(int): ";
    cin >> experience; m_professor.SetExperience(experience);
    cout << "Input faculty of professor: ";
    cin >> faculty; m_professor.SetFaculty(faculty);
    cout << endl;
    _Line;
    cout << "Professor created:" << endl;
    cout << "Professor\nName: " << m_professor.GetName() << endl << "Age: " << m_professor.GetAge() << endl << "Work: " << m_professor.GetWork() << endl << "Experience: " << m_professor.GetExperience() << endl << "Faculty: " << m_professor.GetFaculty() << endl;
    cout << endl;
    Tab_Line;
}

void University::implement_projects(void)
{
    // TODO : implement
}

void University::create_special_departments(void)
{
    // TODO : implement
}

void University::create_conditions_for_project_implementation(void)
{
    // TODO : implement
}

void University::generate_new_technology(void)
{
    // TODO : implement
}


 * Module:  University.h
#if !defined(__ClassDiagram_University_h)
#define __ClassDiagram_University_h

#include "stdafx.h"
#include "Student.h"
#include "Professor.h"
#include<string>
#include<iostream>
#include<vector>
using namespace std;

class Student;
class Professor;

class University
{
protected:
private:

    Student m_student;
    Professor m_professor;

    std::string name;
   int number_of_students;
   int number_of_teachers;
   int number_of_faculties;

public:
    University();
    University(string, int, int,int);
    University(const University&);
    University(string);
    ~University();

   void implement_projects(void);
   void add_student(void);
   void add_professor(void);
   void create_special_departments(void);
   void create_conditions_for_project_implementation(void);
   void generate_new_technology(void);
   std::string GetName();
   int GetNumberOfStudents();
   int GetNumberOfTeachers();
   int GetNumberOfFaculties();
   void SetName(std::string );
   void SetNumberOfStudents(int );
   void SetNumberOfTeachers(int );
   void SetNumberOfFaculties(int );
   
  /* Student** student;
   Professor** professor;
   */
};

#endif

Категорія: 11 клас (академічний) | Додав: admin (01.01.2016)
Переглядів: 12
Пошук
Статистика

Онлайн всього: 1
Гостей: 1
Користувачів: 0
Copyright MyCorp © 2019
Безкоштовний хостинг uCoz