Complex Arithmetic

W. Christian

Davidson College

Complex

Build a Delphi object using the Complex Class Interface declaration given below. Build a small test application that demonstrates each of the objects methods.


type
  TComplex = class
    Re:Double;					{Real part of the cNumber.}
    Im:Double;					{Imaginary part of the cNumber.}
    constructor create(a,b:Double);
    procedure equate(z:TComplex);		{set self equal to z}
    function magnitude:Double;
    function phase:Double;
    procedure conjugate;
    procedure add(z:TComplex);			{Adds z to self.}
    procedure multiply(z:TComplex);		{Multiplies self by z.}
    procedure divide(z:TComplex);		{Divides self by z.}
  end;