type cl = class
a: integer;
constructor create(b: integer);
procedure setval(b: integer);
function getval: integer;
procedure sq;
end;
constructor cl.create(b: integer);
begin
a : = b;
procedure cl.setval(b: integer);
function cl.getval: integer;
getval : = a;
procedure cl.sq;
if a < 0 then
writeln('a ^ 2 = ', a * a)
else
writeln('error');
var
obj: cl;
a : integer;
write('a = ');
readln(a);
obj : = cl.create(a);
obj.sq;
readln;
obj.destroy;
end.
type cl = class
a: integer;
constructor create(b: integer);
procedure setval(b: integer);
function getval: integer;
procedure sq;
end;
constructor cl.create(b: integer);
begin
a : = b;
end;
procedure cl.setval(b: integer);
begin
a : = b;
end;
function cl.getval: integer;
begin
getval : = a;
end;
procedure cl.sq;
begin
if a < 0 then
writeln('a ^ 2 = ', a * a)
else
writeln('error');
end;
var
obj: cl;
a : integer;
begin
write('a = ');
readln(a);
obj : = cl.create(a);
obj.sq;
readln;
obj.destroy;
end.