Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project5;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- System.SysUtils;
- Type ExpCom = class (TObject)
- private
- r , q : real;
- public
- Constructor Create(newR :real ; newQ : real);
- // procedure Sum (one:ExpCom ; two : ExpCom);
- function getR : real;
- Function getQ : real ;
- procedure SetR(newR : real) ;
- procedure SetQ( newQ: real);
- procedure Display ;
- end;
- Constructor ExpCom.Create;
- begin
- r:= NewR;
- q:= newQ;
- end;
- Function ExpCom.getR;
- begin
- getR := r;
- end;
- Function ExpCom.getQ;
- begin
- getQ := q;
- end;
- procedure ExpCom.SetR(newR: Real);
- begin
- r:= newR;
- end;
- procedure ExpCom.SetQ(newQ: Real);
- begin
- q:= newQ;
- end;
- procedure ExpCom.Display;
- begin
- writeln( 'A = ', getR:8:2 );
- writeln( 'fi = ', getQ : 8:2);
- writeln( 'sum = ' + FloatTOStr(getR) + 'e^(j*'+ FloatTOStr(getQ) + ')');
- end;
- procedure Sum(one: ExpCom; two: ExpCom);
- var x , y: real ;
- z : ExpCom;
- begin
- x:= one.getR * cos(one.getQ) + two.getR * cos (two.getQ);
- y:= one.getR * sin(one.getQ) + two.getR * sin (two.getQ);
- z.setr(sqrt(x* x + y* y));
- z.setQ (arctan (y / x));
- writeln( 'sum = ' + FloatTOStr(z.getR) + 'e^(j*'+ FloatTOStr(z.getQ) + ')');
- end;
- var
- z1 ,z2 , z3 : ExpCom ;
- begin
- z1 := ExpCom.Create(10 ,10);
- z2 := ExpCOm.Create(5, 5);
- Sum(z1 , z2);
- z1.Display;
- z2.Display;
- readln;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement