Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
program GalkaVV;
uses AbsObj,crt;
type
TPredMark=record
Pred:string;
Mark:Byte;
end;
PParamItem=^TParamItem;
TParamItem=record
Name,SurName:string[20];
Year,Group:word;
Marks: array [1..10] of TPredMark;
end;
PParamFifo=^TParamFifo;
TParamFifo=object (TFifo)
{ private
AList,BList:PListItem;
public
constructor Init;
destructor Done;
procedure Put(Element: pointer);
function Get:pointer;}
procedure PutStudent(AItem:TParamItem);
procedure GetStudent(var AItem:TParamItem);
procedure FreeItem(AItem: pointer); virtual;
end;
procedure TParamFifo.FreeItem(AItem: pointer);
var
Tmp:PParamItem;
begin
Tmp:=AItem;
if Tmp<>nil then Dispose(Tmp);
end;
procedure TParamFifo.PutStudent(AItem:TParamItem);
var
Tmp:PParamItem;
i:byte;
begin
New(Tmp);
Tmp^:=AItem;
Put(Tmp);
end;
procedure TParamFifo.GetStudent(var AItem:TParamItem);
var
Tmp:PParamItem;
begin
if AList<>nil then
begin
if AList^.Data<>nil then
begin
Tmp:=AList^.Data;
AItem:=Tmp^;
end;
FreeItem(Get);
end;
end;
var
List:PParamFifo;
T:TParamItem;
begin
New(List,Init);
with List^ do
begin
PutStudent(T);
GetStudent(T);
end;
Dispose(List,Done);
end.
uses AbsObj,crt;
type
TPredMark=record
Pred:string;
Mark:Byte;
end;
PParamItem=^TParamItem;
TParamItem=record
Name,SurName:string[20];
Year,Group:word;
Marks: array [1..10] of TPredMark;
end;
PParamFifo=^TParamFifo;
TParamFifo=object (TFifo)
{ private
AList,BList:PListItem;
public
constructor Init;
destructor Done;
procedure Put(Element: pointer);
function Get:pointer;}
procedure PutStudent(AItem:TParamItem);
procedure GetStudent(var AItem:TParamItem);
procedure FreeItem(AItem: pointer); virtual;
end;
procedure TParamFifo.FreeItem(AItem: pointer);
var
Tmp:PParamItem;
begin
Tmp:=AItem;
if Tmp<>nil then Dispose(Tmp);
end;
procedure TParamFifo.PutStudent(AItem:TParamItem);
var
Tmp:PParamItem;
i:byte;
begin
New(Tmp);
Tmp^:=AItem;
Put(Tmp);
end;
procedure TParamFifo.GetStudent(var AItem:TParamItem);
var
Tmp:PParamItem;
begin
if AList<>nil then
begin
if AList^.Data<>nil then
begin
Tmp:=AList^.Data;
AItem:=Tmp^;
end;
FreeItem(Get);
end;
end;
var
List:PParamFifo;
T:TParamItem;
begin
New(List,Init);
with List^ do
begin
PutStudent(T);
GetStudent(T);
end;
Dispose(List,Done);
end.
Соседние файлы в папке Вопросы к экзамену с ответами и демо-программами на Паскале