Кабінет 208
Головна | Реєстрація | Вхід
Неділя, 28.04.2024, 08:49
Меню сайту
Форма входу

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

Класи в С++ (шоста)

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

using namespace std;

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


int main()
{
    Tab_Line;
    cout << " Version 6 by ????" << 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");
    system("pause");
    return 0;
}


 * 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"
#define Tab_Line cout << "========================================================================================================" << "\n"

//Project& Project::operator ++()//Перевантаження унарного оператора постфіксного інкременту
//{
//    term_of_execution += 1;
//    return *this;
//}
//
//Project Project::operator ++(int)//Перевантаження унарного оператора префіксного інкременту
//{
//    Project project = *this;
//    ++*this;
//    return project;
//}
//Project Project::operator +(int  i)//перевантаження бінарного оператора
//{
//    number_of_worker += i;
//    return *this;
//}
//
//
//Project Project::operator =(Project pro)//перевантження оператора присвоєння
//{
//    string name, phone;
//    pro.getInfo(&description, &term_of_execution, &number_of_worker, &name);
//    return Project(name, description, term_of_execution, number_of_worker);
//}
//
//
//ostream& operator << (std::ostream& os, const Project& pro)//Перевантажений оператор виводу
//{
//    std::string name, description;
//    int term_of_execution, number_of_worker;
//    Project project = pro;
//    project.getInfo(&description, &term_of_execution, &number_of_worker, &name);
//    os << name << " " << description << " " << term_of_execution << " " << number_of_worker << "\n";
//    return os;
//}
//
//istream& operator >> (std::istream& is, Project& pro)//Перевантажений оператор вводу
//{
//    std::string name, description;
//    int term_of_execution, number_of_worker;
//    cout << "Enter name: ";
//    is >> name;
//    cout << "Enter description: ";
//    is >> description;
//    cout << "Enter term of execution(int): ";
//    is >> term_of_execution;
//    cout << "Enter number of worker(int): ";
//    is >> number_of_worker;
//
//    pro.setInfo(description, term_of_execution, number_of_worker, name);
//    return is;
//}
//void Project::getInfo(std::string* description, int* term_of_execution, int* number_of_worker, std::string* name)
//{
//    *name = this->name;
//    *description = this->description;
//    *term_of_execution = this->term_of_execution;
//    *number_of_worker = this->number_of_worker;
////    *name = this->name;
//}
//
//void Project::setInfo(std::string description, int term_of_execution, int number_of_worker, std::string name)
//{
//    this->name = name;
//    this->description = description;
//    this->term_of_execution = term_of_execution;
//    this->number_of_worker = number_of_worker;
////    this->name = name;
//}

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

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

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

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() :m_company(), m_university(), m_ministry(), name(""), description(""), term_of_execution(1), number_of_worker(1){};// конструктор за замовченням
    Project(string n, string d, int t, int numb) :m_company("", 1, "", ""), m_university("", 1, 1, 1), m_ministry("", 1, 1), name(n), description(d), term_of_execution(t), number_of_worker(numb){};// конструктор ініціалізації
    ~Project(){};// деструктор

//    void getInfo(std::string* description, int* term_of_execution, int* number_of_worker, std::string* name);
//    void setInfo(std::string description, int term_of_execution, int number_of_worker, std::string name);

   void start(void);
   void add_company(void);
   void add_ministry(void);
   void add_university(void);

   void SetName(std::string );
   void SetDescription(std::string );
   void SetTermOfExecution(int );
   void SetNumberOfWorker(int );

   string Project::GetName() const
   {
       return this->name;
   }
   string Project::GetDescription() const
   {
       return this->description;
   }
   inline int Project::GetTermOfExecution()
   {
       return this->term_of_execution;
   }
   inline int Project::GetNumberOfWorker()
   {
       return this->number_of_worker;
   }
   //Project& Project::operator ++();///Перевантажений оператор постфіксного інкременту
   //Project Project::operator ++(int);///Перевантажений оператор префіксного інкременту
   //Project Project::operator +(int  i);///Перевантажений оператор суми
   //Project Project::operator =(Project pro);//перевантження оператора присвоєння
   //friend std::ostream& operator << (std::ostream& os, const Project& pro);//Перевантажений оператор виводу
   //friend std::istream& operator >> (std::istream& is, Project& pro);//Перевантажений оператор вводу
  /*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::operator ++()//Перевантаження унарного оператора постфіксного інкременту
//{
//    number_of_employees += 1;
//    return *this;
//}
//
//Company Company::operator ++(int)//Перевантаження унарного оператора префіксного інкременту
//{
//    Company company = *this;
//    ++*this;
//    return company;
//}
//Company Company::operator +(int  i)//перевантаження бінарного оператора
//{
//    number_of_employees += i;
//    return *this;
//}
//
//Company Company::operator =(Company comp)//перевантження оператора присвоєння
//{
//    string name, phone;
//    comp.getInfo(&number_of_employees, &location, &type_of_employment, &name);
//    return Company( name, number_of_employees,  location,  type_of_employment);
//}
//
//
//ostream& operator << (std::ostream& os, const Company& comp)//Перевантажений оператор виводу
//{
//    std::string name, location, type_of_employment;
//    int number_of_employees;
//    Company company = comp;
//    company.getInfo(&number_of_employees, &location, &type_of_employment, &name);
//    os << name << " " << number_of_employees << " " << location << " " << type_of_employment << "\n";
//    return os;
//}
//
//istream& operator >> (std::istream& is, Company& comp)//Перевантажений оператор вводу
//{
//    std::string name, location, type_of_employment;
//    int number_of_employees;
//    cout << "Enter name: ";
//    is >> name;
//    cout << "Enter number of employees(int): ";
//    is >> number_of_employees;
//    cout << "Enter location: ";
//    is >> location;
//    cout << "Enter type of employment: ";
//    is >> type_of_employment;
//
//    comp.setInfo(number_of_employees, location, type_of_employment, name);
//    return is;
//}
//void Company::getInfo(int* number_of_employees, std::string* location, std::string* type_of_employment, std::string* name)
//{
//    *name = this->name;
//    *number_of_employees = this->number_of_employees;
//    *location = this->location;
//    *type_of_employment = this->type_of_employment;
//    *name = this->name;
//}
//
//void Company::setInfo(int number_of_employees, std::string location, std::string type_of_employment, std::string name)
//{
//    this->name = name;
//    this->number_of_employees = number_of_employees;
//    this->location = location;
//    this->type_of_employment = type_of_employment;
//    this->name = name;
//}

 


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

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

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

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.Set_name(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.Get_name() << 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() : m_employee(), name(""), number_of_employees(1), location(""), type_of_employment(""){}; // конструктор за замовченням
    Company(std::string n, int numb, std::string l, std::string t) :m_employee("dd", 1, "ff", 1), name(n), number_of_employees(numb), location(l), type_of_employment(t){};// конструктор ініціалізації
    ~Company() {}; // деструктор

    //void getInfo(int* number_of_employees, std::string* location, std::string* type_of_employment, std::string* name);///<Гетер для атрибутів компанії
    //void setInfo(int number_of_employees, std::string location, std::string type_of_employment, std::string name);//сетер для атрибутів компанії


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

   string Company::GetName() const
   {
       return this->name;
   }
   inline int Company::GetNumberOfEmployee()
   {
       return this->number_of_employees;
   }
   string Company::GetLocation() const
   {
       return this->location;
   }
   inline string Company::GetTypeOfEmployment()
   {
       return this->type_of_employment;
   }


   //Company& Company::operator ++();///Перевантажений оператор постфіксного інкременту
   //Company Company::operator ++(int);///Перевантажений оператор префіксного інкременту
   //Company Company::operator +(int  i);///Перевантажений оператор суми
   //Company Company::operator =(Company comp);//перевантження оператора присвоєння
   //friend std::ostream& operator << (std::ostream& os, const Company& comp);//Перевантажений оператор виводу
   //friend std::istream& operator >> (std::istream& is, Company& comp);//Перевантажений оператор вводу

  // 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;


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

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

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

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

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
}


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

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


public:
    Employee() :Person(), age(1), work(""), salary(1){}; // конструктор за замовченням
    Employee(std::string n, int a, std::string w, int s) :Person(n), age(a), work(w), salary(s){}; // конструктор ініціалізації
    ~Employee(){}; // деструктор

   void give_project(void);
   void provide_resources(void);
   void keeps_track_implementation(void);
   void takes_job(void);

   void SetName(std::string);
   void SetAge(int);
   void SetWork(std::string);
   void SetSalary(int);

   /*string Employee::GetName() const
   {
       return this->name;
   }*/
   int Employee::GetAge() const
   {
       return this->age;
   }
   inline string Employee::GetWork()
   {
       return this->work;
   }
   inline int Employee::GetSalary()
   {
       return this->salary;
   }

};

#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;

//ostream& operator << (std::ostream& os, const Ministry& minis)//Перевантажений оператор виводу
//{
//    std::string name;
//    int number_of_employee, budget;
//    Ministry ministry = minis;
//    ministry.getInfo(&number_of_employee, &budget, &name);
//    os << name << " " << number_of_employee << " " << budget <<  "\n";
//    return os;
//}
//
//istream& operator >> (std::istream& is, Ministry& minis)//Перевантажений оператор вводу
//{
//    std::string name;
//    int number_of_employee, budget;
//    cout << "Enter name: ";
//    is >> name;
//    cout << "Enter number of employees(int): ";
//    is >> number_of_employee;
//    cout << "Enter budget(int): ";
//    is >> budget;
//
//    minis.setInfo(number_of_employee, budget, name);
//    return is;
//}
//void Ministry::getInfo(int* number_of_employee, int* budget, std::string* name)
//{
//    *name = this->name;
//    *number_of_employee = this->number_of_employee;
//    *budget = this->budget;
//    *name = this->name;
//}
//
//void Ministry::setInfo(int number_of_employee, int budget, std::string name)
//{
//    this->name = name;
//    this->number_of_employee = number_of_employee;
//    this->budget = budget;
//    this->name = 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;
}

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

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

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


 * 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() :name(""), budget(1), number_of_employee(1){};// конструктор за замовченням
    Ministry(string n, int b, int numb): name(n), budget(b), number_of_employee(numb){}; // конструктор ініціалізації
    ~Ministry(){}; // деструктор

    //void getInfo(int* number_of_employee, int* budget, std::string* name);
    //void setInfo(int number_of_employee, int budget, std::string name);
    
   void set_framework_for_university(void);
   void provide_staff(void);
   void provide_necessary_resources(void);
   
   void SetName(std::string); // встановити ім'я
   void SetNumberOfEmployee(int); // встановити кількість працівників
   void SetBudget(int); // встановити бюджет

   string Ministry::GetName() const
   {
       return this->name;
   }
   inline int Ministry::GetNumberOfEmployee()
   {
       return this->number_of_employee;
   }
   inline int  Ministry::GetBudget()
   {
       return this->budget;
   }
  // friend std::ostream& operator << (std::ostream& os, const Ministry& minis);//Перевантажений оператор виводу
  // friend std::istream& operator >> (std::istream& is, Ministry& minis);//Перевантажений оператор вводу
};

#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;


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

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

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

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

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

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

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

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


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

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

public:
    Professor() :Person(), age(1), work(""), experience(1), faculty(""){};// конструктор за замовченням
    Professor(string n, int a, string w, int e, string f) :Person(n), age(a), work(w), experience(e), faculty(f){};// конструктор ініціалізації
    ~Professor(){}; // деструктор

   void teach_student(void);
   void work_on_the_project(void);
   void conduct_research(void);
 
  // void SetName(std::string);
   void SetAge(int);
   void SetWork(std::string);
   void SetExperience(int);
   void SetFaculty(std::string);

   /*string Professor::GetName() const
   {
       return this->name;
   }*/
   int Professor::GetAge() const
   {
       return this->age;
   }
   inline string Professor::GetWork()
   {
       return this->work;
   }
   int Professor::GetExperience() const
   {
       return this->experience;
   }
   inline string Professor::GetFaculty()
   {
       return this->faculty;
   }
};

#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;

 

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

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

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

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

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


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

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

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


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

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

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

public:
    Student() :Person(), age(1), faculty(""), course(1), group(""){};// конструктор за замовченням
    Student(string n, int a, string f, int c, string g) :Person(n), age(a), faculty(f), course(c), group(g){};// конструктор ініціалізації
    ~Student(){};// деструктор

   void study_at_univer(void);
   void working_on_a_project(void);
   void conducts_research(void);
 
   //void SetName(std::string);
   void SetAge(int);
   void SetGroup(std::string);
   void SetCourse(int);
   void SetFaculty(std::string);

  /* string Student::GetName() const
   {
       return this->name;
   }*/
   int Student::GetAge() const
   {
       return this->age;
   }
   inline string Student::GetGroup()
   {
       return this->group;
   }
   inline int Student::GetCourse()
   {
       return this->course;
   }
   inline string Student::GetFaculty()
   {
       return this->faculty;
   }
};

#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::operator ++()//Перевантаження унарного оператора постфіксного інкременту
//{
//    number_of_students += 1;
//    return *this;
//}
//
//University University::operator ++(int)//Перевантаження унарного оператора префіксного інкременту
//{
//    University university = *this;
//    ++*this;
//    return university;
//}
//University University::operator +(int  i)//перевантаження бінарного оператора
//{
//    number_of_teachers += i;
//    return *this;
//}
//
//
//University University::operator =(University univ)//перевантження оператора присвоєння
//{
//    string name, phone;
//    univ.getInfo(&number_of_students, &number_of_teachers, &number_of_faculties, &name);
//    return University(name, number_of_students, number_of_teachers, number_of_faculties);
//}
//
//
//ostream& operator << (std::ostream& os, const University& univ)//Перевантажений оператор виводу
//{
//    std::string name;
//    int number_of_students, number_of_teachers, number_of_faculties;
//    University university = univ;
//    university.getInfo(&number_of_students, &number_of_students, &number_of_faculties, &name);
//    os << name << " " << number_of_students << " " << number_of_students << " " << number_of_faculties << "\n";
//    return os;
//}
//
//istream& operator >> (std::istream& is, University& univ)//Перевантажений оператор вводу
//{
//    std::string name;
//    int number_of_students, number_of_teachers, number_of_faculties;
//    cout << "Enter name: ";
//    is >> name;
//    cout << "Enter number of students(int): ";
//    is >> number_of_students;
//    cout << "Enter number of teachers(int): ";
//    is >> number_of_teachers;
//    cout << "Enter number of faculties(int): ";
//    is >> number_of_faculties;
//
//    univ.setInfo(number_of_students, number_of_teachers, number_of_faculties, name);
//    return is;
//}
//void University::getInfo(int* number_of_students, int* number_of_teachers, int* number_of_faculties, std::string* name)
//{
//    *name = this->name;
//    *number_of_students = this->number_of_students;
//    *number_of_teachers = this->number_of_teachers;
//    *number_of_faculties = this->number_of_faculties;
//    *name = this->name;
//}
//
//void University::setInfo(int number_of_students, int number_of_teachers, int number_of_faculties, std::string name)
//{
//    this->name = name;
//    this->number_of_students = number_of_students;
//    this->number_of_teachers = number_of_teachers;
//    this->number_of_faculties = number_of_faculties;
//    this->name = name;
//}

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

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

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

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.Set_name(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.Get_name() << "\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.Set_name(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.Get_name() << 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() :m_student(), m_professor(), name(""), number_of_students(1), number_of_teachers(1), number_of_faculties(1){};// конструктор за замовченням
    University(string n, int ns, int nt, int nf) :m_student("ss", 1, "", 1, ""), m_professor("ss", 1, "", 1, ""), name(n), number_of_students(ns), number_of_teachers(nt), number_of_faculties(nf){};// конструктор ініціалізації
    ~University(){}; // деструктор

    //void getInfo(int* number_of_students, int* number_of_teachers, int* number_of_faculties, std::string* name);///<Гетер для атрибутів компанії
    //void setInfo(int number_of_students, int number_of_teachers, int number_of_faculties, std::string name);//сетер для атрибутів компанії


   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);

   void SetName(std::string );
   void SetNumberOfStudents(int );
   void SetNumberOfTeachers(int );
   void SetNumberOfFaculties(int );

   string University::GetName() const
   {
       return this->name;
   }
   int University::GetNumberOfStudents() const
   {
       return this->number_of_students;
   }
   int University::GetNumberOfTeachers() const
   {
       return this->number_of_teachers;
   }
   inline int University::GetNumberOfFaculties()
   {
       return this->number_of_faculties;
   }


  // University& University::operator ++();///Перевантажений оператор постфіксного інкременту
  // University University::operator ++(int);///Перевантажений оператор префіксного інкременту
  // University University::operator +(int  i);///Перевантажений оператор суми
  // University University::operator =(University univ);//перевантження оператора присвоєння
  // friend std::ostream& operator << (std::ostream& os, const University& univ);//Перевантажений оператор виводу
  // friend std::istream& operator >> (std::istream& is, University& univ);//Перевантажений оператор вводу
  /* Student** student;
   Professor** professor;
   */
};

#endif

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

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