
23.12.2009, 11:24
|
Прохожий
|
|
Регистрация: 22.12.2009
Сообщения: 8
Репутация: 10
|
|
Ну, допустим, вот один из юнитов программы (в каждом юните свой класс). Это такой контейнер, он умеет считывать и выдавать информацию.
Здесь три метода, как вы видите.
нужно, чтобы в этом юните по сути осталось только описание класса, а описания методов должны быть в отдельных файлах.
Дерективой я пользоваться умею. Может кто-нибудь знает другие способы реализации?
Код:
unit Box;
interface
type
Tbox=class
a: array [1..10] of Pointer;
kol:integer;
public
destructor Close_box();
constructor Read_Box();
procedure Write_box();
end;
var
booo:Tbox;
implementation
uses Shar, Parallep ,SysUtils,Base, unit1 ;
var
sh : PSharik;
ps : PSparal;
{procedure Tbox.Write_box();
var
i:integer;
FOut: TextFile;
begin
assign(FOut,'Out.txt');
rewrite(FOut);
writeln(FOut,'Kolichestvo elementov v konteiynere: '+inttostr( booo.kol));
for i := 1 to booo.kol do
begin
if PSharik(booo.a[i])^.PrintTe=1 then
begin
sh:=PSharik( booo.a[i]);
writeln( i,': '+sh^.Print(sh^));
writeln(FOut, i,': '+sh^.Print(sh^));
end
else
if PSparal(booo.a[i])^.PrintTe=2 then
begin
ps:=PSparal(booo.a[i]);
writeln( i,': '+ps^.Print(ps^));
writeln(FOut, i,': '+ps^.Print(ps^));
end;
end;
close(FOut);
end;
}
destructor Tbox.Close_box();
var
i:integer;
begin
for i := 1 to booo.kol do
begin
dispose(booo.a[i]);
booo.a[i]:=nil;
end;
end;
constructor Tbox.Read_Box();
var
fi:TextFile;
s,s1,s2,a,b,c,z: string;
i,j,kol:integer;
begin
AssignFile(fi,'in.txt');
reset(fi);
j:=0;
while (not eof(fi))and (booo.kol<10) do
begin
inc(j);
if booo.kol<11 then //Переполнение
begin
Readln(fi,s);
Readln(fi,s1);
Readln(fi,s2);
Readln(fi,z);
if s<>'' then
begin
if StrToInt(s)=1 then // опред. фиг.
begin
new(sh);
inc(booo.kol);
booo.a[j]:=sh;
sh^:= Sharik.Create;
sh^.SetParam( sh^, strtoint(s1),strtofloat(s2),j,1);
end
else
begin
new(ps);
booo.a[j]:=ps;
ps^:=Parallelepiped.Create;
inc(booo.kol);
kol:=0;
a:='';
b:='';
c:='';
for i := 1 to length(s2) do // деление на а b c
begin
if s2[i]<>' ' then
begin
if kol=0 then
a:=a+s2[i]
else
if kol=1 then
b:=b+s2[i]
else
c:=c+s2[i]
end else
inc(kol);
end;
ps^.SetParam(ps^,StrToInt(a),StrToInt(b),StrToInt(c),StrToFloat(s1),j,StrToInt(s));
end;
end;
end;
end;
end;
end.
|