Теория и практика объектно-ориентированного программирования. Ноткин А.М. - 39 стр.

UptoLike

Составители: 

40
if EndState=0
then Valid:=false
else Valid:=true;
End;
Procedure TDevice.EndExec;
begin
EndState:=1;
end;
Constructor TCalc.Init;
Var p:PObject;
begin
inherited Init;
sum:=new(PReg,Init);
r1:=new(PReg,Init);
{вставить в КАЛЬКУЛЯТОР элементы TAdd,TSub,TMult,TDel }
end;
Procedure TCalc.HandleEvent(Var Event:TEvent);
Begin
if Event.What=evMessage then
{обработка команд TCalc}
begin
case Event.Command of
cmQuit:EndExec;
cmGet:OutPutX;
cmSet:InPutX(Event.A);
cmHelp:Help
else {обработка команд устройств }
begin
inherited HandleEvent(Event);
exit;
end;
end;{case}
ClearEvent(Event)
end;{if then}
End;
Procedure TCalc.Run;
Begin
writeln('Вводите команды. “q” выход,“h” помощь);
                             40
if EndState=0
   then Valid:=false
   else Valid:=true;
End;

Procedure TDevice.EndExec;
begin
EndState:=1;
end;

Constructor TCalc.Init;
Var p:PObject;
begin
inherited Init;
sum:=new(PReg,Init);
r1:=new(PReg,Init);
{вставить в КАЛЬКУЛЯТОР элементы TAdd,TSub,TMult,TDel }
end;

Procedure TCalc.HandleEvent(Var Event:TEvent);
Begin
if Event.What=evMessage then
{обработка команд TCalc}
begin
 case Event.Command of
 cmQuit:EndExec;
 cmGet:OutPutX;
 cmSet:InPutX(Event.A);
 cmHelp:Help
 else {обработка команд устройств }
    begin
    inherited HandleEvent(Event);
    exit;
    end;
end;{case}
ClearEvent(Event)
end;{if then}
End;

Procedure TCalc.Run;
Begin
writeln('Вводите команды. “q” − выход,“h” − помощь);