Complex Arithmetic

W. Christian

Davidson College


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

  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.}