Nav apraksta

main.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //************************************
  2. // By Ive 4, June 4 *
  3. //************************************
  4. #include<iostream>
  5. #include "xyplotwindow.h"
  6. #include <QApplication>
  7. using namespace std;
  8. //**********************************************************
  9. // This function is to illustrate the difference between *
  10. // pass by value and pass by reference *
  11. //**********************************************************
  12. void illustration(int paramValue, int &paramRef)
  13. {
  14. paramValue=1;
  15. paramRef=1;
  16. cout << endl << "The content of paramValue is: " << paramValue << endl
  17. << "The content of paramRef is: " << paramRef << endl;
  18. }
  19. //************************************
  20. // Functions circle *
  21. //************************************
  22. void circle(double p, double &xCoord, double &yCoord)
  23. {
  24. xCoord = 5 * cos(p);
  25. yCoord = 5 * sin(p);
  26. }
  27. //Overloaded Funcion circle
  28. // YOUR CODE HERE
  29. //************************************
  30. // Function butterfly *
  31. //************************************
  32. // YOUR CODE HERE
  33. //***************
  34. // Function main *
  35. //***************
  36. int main(int argc, char *argv[])
  37. {
  38. QApplication a(argc, argv);
  39. XYPlotWindow wCircleR5;
  40. XYPlotWindow wCircle;
  41. XYPlotWindow wButterfly;
  42. double r;
  43. double y = 0.00;
  44. double x = 0.00;
  45. double increment = 0.01;
  46. int argValue=0, argRef=0;
  47. // invoke the function illustration to view the contents of variables by value and by reference
  48. illustration(argValue,argRef);
  49. cout << endl << "The content of argValue is: " << argValue << endl
  50. << "The content of argRef is: " << argRef << endl;
  51. // repeat for several values of the angle t
  52. for (double t = 0; t < 16*M_PI; t = t + increment)
  53. {
  54. // invoke circle with the angle t and reference variables x, y as arguments
  55. circle(t,x,y);
  56. // add the point (x,y) to the graph of the circle
  57. wCircleR5.AddPointToGraph(x,y);
  58. // invoke circle with the radius r, the angle t and reference variables x, y as arguments
  59. // YOUR CODE HERE
  60. // add the point (x,y) to the graph of the circle
  61. // YOUR CODE HERE
  62. // invoke butterfly with the angle t and reference variables x, y as arguments
  63. // YOUR CODE HERE
  64. // add the point (x,y) to the graph of the butterfly
  65. // YOUR CODE HERE
  66. }
  67. // After all the points have been added, plot and show the graphs
  68. wCircleR5.Plot();
  69. wCircleR5.show();
  70. // YOUR CODE HERE
  71. return a.exec();
  72. }