Pages = new int;*Pages=0;YearIzd = new int;
*YearIzd=0;Number = new int;*Number=0;
NYear = new int;*NYear=0;}
Magazine(AnsiString N,int P,int Y,int Num,int NY):Author()
{MagName = new AnsiString;*MagName=N;
Pages = new int;*Pages=P;YearIzd = new int;
*YearIzd=Y;Number = new int;*Number=Num;NYear = new int;*NYear=NY;}
//destructor
~Magazine() {delete MagName,Pages,YearIzd,Number,NYear;}
};
//realizations of not realized methods in classes
//for class Library
void Library::printinfo()
{
Form1->Memo1->Lines->Add("-------------------------");
Form1->Memo1->Lines->Add("LIBRARY INFO:");
Form1->Memo1->Lines->Add("Name: "+*LibName);
Form1->Memo1->Lines->Add("Fond Size: "+IntToStr(*Size));
};
//for class Author
void Author::printinfo()
{
AnsiString
Birthday=IntToStr(Day)+"."+IntToStr(Month)+"."+IntToStr(Year);
Form1->Memo1->Lines->Add("-------------------------");
Form1->Memo1->Lines->Add("AUTHOR INFO");
Form1->Memo1->Lines->Add("Name: "+AuthorName);
Form1->Memo1->Lines->Add("Birthday: "+Birthday);
Form1->Memo1->Lines->Add("Nationality: "+*Nation);
};
//for class Book
void Book::printinfo()
{
Form1->Memo1->Lines->Add("-------------------------");
Form1->Memo1->Lines->Add("BOOK INFO");
Form1->Memo1->Lines->Add("Author: "+Author::getname());
Form1->Memo1->Lines->Add
("Name: "+*BookName+" ("+IntToStr(*Pages)+" pages)");
Form1->Memo1->Lines->Add("Year Of Izd: "+IntToStr(*YearIzd));
};
void Book::setauthor(Author *A)
{
Author::setname(A->getname());
Year=A->Year;Month=A->Month;Day=A->Day;*Nation=*A->Nation;
};
//for class Magazine
void Magazine::printinfo()
{
Form1->Memo1->Lines->Add("-------------------------");
Form1->Memo1->Lines->Add("MAGAZINE INFO");
Form1->Memo1->Lines->Add("Author: "+Author::getname());
Form1->Memo1->Lines->Add
("Name: "+*MagName+" ("+IntToStr(*Pages)+" pages)");
Form1->Memo1->Lines->Add("Year Of Izd: "+IntToStr(*YearIzd));
Form1->Memo1->Lines->Add
("Number: "+IntToStr(*Number)+"("+IntToStr(*NYear)+")");
};
void Magazine::setauthor(Author *A)
{
Author::setname(A->getname());
Year=A->Year;Month=A->Month;Day=A->Day;*Nation=*A->Nation;
};
//MAIN PROGRAM
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//making library
Library *L1=new Library;L1->setname("KHSTU Library");
L1->FondName="Khabarovsk Libraries";L1->Size[0]=20;
//making & init derived objects
Author *A1=new Author("Pushkin",1,12,1799,"Russia");
Author *A2=new Author("Lermontov",11,9,1824,"Russia");
Author *A3=new Author("Bessonov",1,12,1975,"Russia");
Book *B1=new Book("Autobiography",300,1998);B1->setauthor(A1);
Book *B2=new Book("Poetry",114,1999);B2->setauthor(A1);
Book *B3=new Book("Hero Of Our Days",154,1998);B3->setauthor(A2);
Magazine *M1=new Magazine("Xakep",90,2003,6,12);M1->setauthor(A3);
//making and fill Container copies of objects
Fond *Cont[8];
Cont[0]=L1;Cont[1]=A1;Cont[2]=A2;Cont[3]=A3;Cont[4]=B1;
Cont[5]=B2;Cont[6]=B3;Cont[7]=M1;
//running method printinfo() for all objects
for (int i=0;i<8;i++) {Cont[i]->printinfo();}
//free memory
for (int i=0;i<8;i++) {delete Cont[i];}
}
//---------------------------------------------------------------------------
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.