Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

[ТП] Лаб 12

.docx
Скачиваний:
23
Добавлен:
14.05.2018
Размер:
38.68 Кб
Скачать

Министерство Образования и Науки Республики Казахстан

Алматинский Университет Энергетики и Связи

Институт Систем Управления и Информационных Технологий

Кафедра IT-инжиниринга

Отчет по

Лабораторной работе №12 Наследование классов в С++

По дисциплине: “Технология программирования”

Вариант №3

Выполнил: ст.гр. ИС-16-2 Ануарбеков Шыңғыс

Приняла: ассистент каф. IT-и Акижанова З.А.

Алматы 2017

Задание 1: создать класс Организация и два класса наследника (Магазины и Торговая сеть).

Программа:

#include <iostream>

#include <string>

#include <Windows.h>

using namespace std;

class Organization

{

private:

int yearOfFoundation;

string nameOfDirector;

public:

Organization()

{

}

Organization (int yearOfFoundation, string nameOfDirector, string product, string location, int frameStructure, string nameOfOrganization)

{

this->yearOfFoundation=yearOfFoundation;

this->nameOfDirector=nameOfDirector;

this->product=product;

this->location=location;

this->frameStructure=frameStructure;

this->nameOfOrganization=nameOfOrganization;

}

void ShowInf(){

cout<<"Название организации:"<<nameOfOrganization<<endl<<"Год основания:"<<yearOfFoundation<<endl<<"Имя директора:"<<nameOfDirector<<endl<<"Предоставляемый продукт:"<<product<<endl<<"Местоположение:"<<location<<endl<<"Кадровый состав офиса(кол-во):"<<frameStructure<<endl;

cout<<"____________________________________________________"<<endl;

}

string product;

protected:

string location;

int frameStructure;

string nameOfOrganization;

};

//ВТОРОЙ КЛАСС

class TredingNetwork : public Organization

{

private:

int NumberOfStores;

public:

TredingNetwork(string nameOfOrganization, int NumberOfStores, string location,int frameStructure)

{

this->nameOfOrganization=nameOfOrganization;

this->location=location;

this->frameStructure=frameStructure;

this->NumberOfStores=NumberOfStores;

}

void ShowInf1()

{

cout<<"Имя организации:"<<nameOfOrganization<<endl<<"Местонахождение:"<<location<<endl<<"Кадровый состав по городу:"<<frameStructure<<endl<<"Количество магазинов в городе:"<<NumberOfStores<<endl;

cout<<"____________________________________________________"<<endl;

}

};

//ТРЕТИЙ КЛАСС

class Shops: public Organization

{

private:

string nameOfAdmin;

float warehouseArea;

string modeOfOperation;

string AddressInCity;

public:

Shops(string nameOfOrganization, string AddressInCity, string modeOfOperation, string nameOfAdmin, string product, string location,

float warehouseArea, int frameStructure)

{

this->nameOfOrganization=nameOfOrganization;

this->AddressInCity=AddressInCity;

this->modeOfOperation=modeOfOperation;

this->nameOfAdmin=nameOfAdmin;

this->product=product;

this->location=location;

this->warehouseArea=warehouseArea;

this->frameStructure=frameStructure;

}

void ShowInf2()

{

cout<<"Имя организации магазина:"<<nameOfOrganization<<endl<<"Адрес в городе:"<<AddressInCity<<endl<<"Режим работы:"<<modeOfOperation<<endl<<"Имя администратора:"<<nameOfAdmin<<endl<<"Преимущественный продукт:"<<product<<endl<<"Город магазина:"<<location<<endl<<"Площадь склада(кв.м):"<<warehouseArea<<endl<<"Персонал магазина:"<<frameStructure;

}

};

int main()

{

setlocale (LC_ALL, "rus");

SetConsoleCP(1251);

SetConsoleOutputCP(1251);

Organization a(1998, "Вячеслав Иванов", "Мужская коллекция одежды", "Алматы", 15, "TOO Style ");

a.ShowInf();

TredingNetwork b("TOO Style ", 25, "Алматы", 358);

b.ShowInf1();

Shops c("TOO Style ", "ТРЦ Мега2", "10:00-22:00", "Стешина Марина", "Мужские костюмы", "Алматы", 12.25, 8);

c.ShowInf2();

return 0;

}

Результат:

Соседние файлы в предмете Технология программирования