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

UptoLike

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

15
begin
result:=IVector.Create;
for i:=1 to Dim do result.comp[i]:=self.comp[i]+v.comp[i];
end;
function IVector.Minus(v: IVector): IVector;
var i: Integer;
begin
result:=IVector.Create;
for i:=1 to Dim do result.comp[i]:=self.comp[i]-v.comp[i];
end;
procedure IVector.Add(v: IVector);
var i: Integer;
begin
for i:=1 to Dim do self.comp[i]:=self.comp[i]+v.comp[i];
end;
procedure IVector.Subtract(v: IVector);
var i: Integer;
begin
for i:=1 to Dim do self.comp[i]:=self.comp[i]-v.comp[i];
end;
function IVector.ScalarProduct(v: IVector): Integer;
var i: Integer;
begin
result:=0;
for i:=1 to Dim do result:=result+self.comp[i]*v.comp[i];
end;
function IVector.GetLength: Real;
var i: Integer;
begin
result:=0;
for i:=1 to Dim do result:=result+sqr(self.comp[i]);
result:=sqrt(result);
end;
function IVector.IsEqual(v: IVector): Boolean;
var i: Integer;
begin
result:=true;
for i:=1 to Dim do
if self.comp[i]<>v.comp[i] then result:=false;
end;
procedure IVector.Assign(v: IVector);
var i: Integer;
begin
for i:=1 to Dim do self.comp[i]:=v.comp[i];
end;
begin
  result:=IVector.Create;
  for i:=1 to Dim do result.comp[i]:=self.comp[i]+v.comp[i];
end;
function IVector.Minus(v: IVector): IVector;
var i: Integer;
begin
  result:=IVector.Create;
  for i:=1 to Dim do result.comp[i]:=self.comp[i]-v.comp[i];
end;
procedure IVector.Add(v: IVector);
var i: Integer;
begin
  for i:=1 to Dim do self.comp[i]:=self.comp[i]+v.comp[i];
end;
procedure IVector.Subtract(v: IVector);
var i: Integer;
begin
  for i:=1 to Dim do self.comp[i]:=self.comp[i]-v.comp[i];
end;
function IVector.ScalarProduct(v: IVector): Integer;
var i: Integer;
begin
  result:=0;
  for i:=1 to Dim do result:=result+self.comp[i]*v.comp[i];
end;
function IVector.GetLength: Real;
var i: Integer;
begin
  result:=0;
  for i:=1 to Dim do result:=result+sqr(self.comp[i]);
  result:=sqrt(result);
end;
function IVector.IsEqual(v: IVector): Boolean;
var i: Integer;
begin
  result:=true;
  for i:=1 to Dim do
     if self.comp[i]<>v.comp[i] then result:=false;
end;
procedure IVector.Assign(v: IVector);
var i: Integer;
begin
  for i:=1 to Dim do self.comp[i]:=v.comp[i];
end;




                                  15