Разработка классов на языке Object Pascal. Соколов Е.В. - 55 стр.

UptoLike

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

procedure DynamicVector.Assign(v: DynamicVector);
var i: Integer;
begin
  if Length(self.comp)=Length(v.comp) then
     for i:=0 to Length(self.comp)-1 do self.comp[i].Assign(v.comp[i])
     else raise Exception.Create('Invalid Operation');
end;
function DynamicVector.AsString: String;
var i: Integer;
begin
  result:='(';
  for i:=0 to Length(self.comp)-1 do begin
     result:=result+self.comp[i].AsString;
     if i=1) and (i<=Length(self.comp))
     then result:=self.comptype.CreateEqualTo(self.comp[i-1])
     else raise Exception.Create('Index is out of bounds');
end;
procedure DynamicVector.SetComp(i: Integer; value: Number);
begin
  if (i>=1) and (i<=Length(self.comp))
     then self.comp[i-1].Assign(value)
     else raise Exception.Create('Index is out of bounds');
end;
function DynamicVector.GetDim: Integer;
begin
  result:=Length(self.comp);
end;
procedure DynamicVector.SetDim(value: Integer);
var i, OldDim: Integer;
begin
  if value<0 then raise Exception.Create('Invalid value');
  if valueLength(self.comp) then begin
     OldDim:=Length(self.comp); SetLength(self.comp, value);
     for i:=OldDim to value-1 do self.comp[i]:=self.comptype.Create;
  end;
end;



                                  55