Добавил:
bagiwow
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Программирование / си++ / 2Semestr / Lab_2 / Lab 2a / fun
.cpp#include <iostream.h>
#include <string.h>
#include "class.h"
//-------------------------------------------------------------------------------
Org::Org()
{
strcpy(name,"Нет Имени");
kol_sotr=0;
next=0;
}
//-------------------------------------------------------------------------------
Org::Org(char* Name,int Kol_sotr)
{
strcpy(name,Name);
kol_sotr=Kol_sotr;
next=0;
}
//-------------------------------------------------------------------------------
Org::Org(const Org& org)
{
strcpy(name,org.name);
kol_sotr=org.kol_sotr;
next=org.next;
}
//-------------------------------------------------------------------------------
Org::~Org()
{}
//-------------------------------------------------------------------------------
StrCom::StrCom():Org()
{
kol_zastr=0;
}
//-------------------------------------------------------------------------------
StrCom::StrCom(char* Name,int Kol_sotr,int Kol_zastr):Org(Name,Kol_sotr)
{
kol_zastr=Kol_zastr;
}
//-------------------------------------------------------------------------------
StrCom::StrCom(const StrCom& str)
{
kol_zastr=str.kol_zastr;
}
//-------------------------------------------------------------------------------
StrCom::~StrCom() {}
//-------------------------------------------------------------------------------
void StrCom::Show()
{
cout<<"Строительная компания: "<<name<<endl;
cout<<"Кол-во сотрудников: "<<kol_sotr<<endl;
cout<<"Кол-во застрахованных: "<<kol_zastr<<endl<<endl;
}
//-------------------------------------------------------------------------------
void StrCom::Add()
{
if (!Beg) Beg=this;
else
{
Org*p=Beg;
while(p->next)
{
p=p->next;
}
if(p!=this) p->next=this;
if(p==this)
{
StrCom*t=new StrCom;
*t=*this;
p->next=t;
}
}
}
//-------------------------------------------------------------------------------
Zavod::Zavod():Org()
{
kol_stan=0;
}
//-------------------------------------------------------------------------------
Zavod::Zavod(char* Name,int Kol_sotr,int Kol_stan):Org(Name,Kol_sotr)
{
kol_stan=Kol_stan;
}
//-------------------------------------------------------------------------------
Zavod::Zavod(const Zavod& zav)
{
kol_stan=zav.kol_stan;
}
//-------------------------------------------------------------------------------
Zavod:: ~ Zavod() {}
//-------------------------------------------------------------------------------
void Zavod::Show()
{
cout<<"Завод: "<<name<<endl;
cout<<"Кол-во сотрудников: "<<kol_sotr<<endl;
cout<<"Кол-во Станков: "<<kol_stan<<endl<<endl;
}
//-------------------------------------------------------------------------------
void Zavod::Add()
{
if (!Beg) Beg=this;
else
{
Org*p=Beg;
while(p->next)
{
p=p->next;
}
if(p!=this) p->next=this;
if(p==this)
{
Zavod*t=new Zavod;
*t=*this;
p->next=t;
}
}
}
//-------------------------------------------------------------------------------
SudCom::SudCom():Org()
{
kol_kor=0;
}
//-------------------------------------------------------------------------------
SudCom::SudCom(char* Name,int Kol_sotr,int Kol_kor):Org(Name,Kol_sotr)
{
kol_kor=Kol_kor;
}
//-------------------------------------------------------------------------------
SudCom::SudCom(const SudCom& sud)
{
kol_kor=sud.kol_kor;
}
//-------------------------------------------------------------------------------
SudCom::~SudCom() {}
//-------------------------------------------------------------------------------
void SudCom::Show()
{
cout<<"Судостроительная компания: "<<name<<endl;
cout<<"Кол-во сотрудников: ");cout<<kol_sotr<<endl;
cout<<"Кол-во кораблей: "); cout<<kol_kor<<endl<<endl;
}
//-------------------------------------------------------------------------------
void SudCom::Add()
{
if (!Beg) Beg=this;
else
{
Org*p=Beg;
while(p->next)
{
p=p->next;
}
if(p!=this) p->next=this;
if(p==this)
{
SudCom*t=new SudCom;
*t=*this;
p->next=t;
}
}
}
//-------------------------------------------------------------------------------
void cout<<char *Str)
{
unsigned char c;
for(int i=0;Str[i]!='\0';i++)
{
c=Str[i];
if(c>127)
{
if(c<240)c-=64;
else c-=16;
}
cout<<c;
}
}
//-------------------------------------------------------------------------------
void Org::Print()
{
Org* p=Beg;
if(!p) {cout<<"Список пуст");cout<<endl;}
while (p)
{
p->Show();
p=p->next;
}
}
//-------------------------------------------------------------------------------