Advertisement
daniv1

Untitled

Apr 29th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.42 KB | None | 0 0
  1. program Project5;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8.   System.SysUtils;
  9.  
  10. Type ExpCom = class (TObject)
  11.  
  12.     private
  13.        r , q : real;
  14.       public
  15.      Constructor Create(newR :real ; newQ : real);
  16.   //  procedure Sum (one:ExpCom ; two : ExpCom);
  17.       function getR : real;
  18.       Function  getQ : real ;
  19.       procedure SetR(newR : real) ;
  20.       procedure SetQ( newQ: real);
  21.       procedure Display ;
  22.  
  23.   end;
  24. Constructor ExpCom.Create;
  25. begin
  26.     r:= NewR;
  27.     q:= newQ;
  28. end;
  29.  
  30. Function ExpCom.getR;
  31. begin
  32.   getR := r;
  33. end;
  34. Function ExpCom.getQ;
  35. begin
  36.             getQ := q;
  37. end;
  38. procedure ExpCom.SetR(newR: Real);
  39. begin
  40.     r:= newR;
  41. end;
  42. procedure ExpCom.SetQ(newQ: Real);
  43. begin
  44.    q:= newQ;
  45. end;
  46. procedure ExpCom.Display;
  47. begin
  48. writeln( 'A = ', getR:8:2 );
  49. writeln( 'fi = ', getQ : 8:2);
  50.    writeln( 'sum = ' +  FloatTOStr(getR) + 'e^(j*'+ FloatTOStr(getQ) + ')');
  51. end;
  52. procedure Sum(one: ExpCom; two: ExpCom);
  53. var x , y: real ;
  54. z : ExpCom;
  55. begin
  56.  x:= one.getR * cos(one.getQ) + two.getR * cos (two.getQ);
  57.    y:= one.getR * sin(one.getQ) + two.getR * sin (two.getQ);
  58.    z.setr(sqrt(x* x + y* y));
  59.    z.setQ (arctan (y / x));
  60.    writeln( 'sum = ' +  FloatTOStr(z.getR) + 'e^(j*'+ FloatTOStr(z.getQ) + ')');
  61. end;
  62.        var
  63.        z1 ,z2 , z3 : ExpCom ;
  64. begin
  65.  
  66. z1 := ExpCom.Create(10 ,10);
  67. z2 := ExpCOm.Create(5, 5);
  68. Sum(z1 , z2);
  69. z1.Display;
  70. z2.Display;
  71. readln;
  72. readln;
  73. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement