No Description

main.cpp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //************************************
  2. // By Ive 4, June 4 *
  3. //************************************
  4. #include<iostream>
  5. #include "xyplotwindow.h"
  6. #include <QApplication>
  7. using namespace std;
  8. /// \fn void illustration(int paramValue, int &paramRef)
  9. /// \~English
  10. /// \brief This function is to illustrate the difference between
  11. /// pass by value and pass by reference
  12. /// \param paramValue parameter passed by value
  13. /// \param paramRef parameter passed by reference
  14. /// \~Spanish
  15. /// \brief Esta funcion es para ilustrar la differencia entre
  16. /// variables pasadas por referencia y pasadas por valor
  17. /// \param paramValue parametro pasado por valor
  18. /// \param paramRef parametro pasado por referencia
  19. void illustration(int paramValue, int &paramRef)
  20. {
  21. paramValue=1;
  22. paramRef=1;
  23. cout << endl << "The content of paramValue is: " << paramValue << endl
  24. << "The content of paramRef is: " << paramRef << endl;
  25. }
  26. /// \fn void circle(double p, double &xCoord, double &yCoord)
  27. /// \~English
  28. /// \brief Function to draw a circle
  29. /// \~Spanish Funcion para dibujar un circulo
  30. void circle(double p, double &xCoord, double &yCoord)
  31. {
  32. xCoord = 5 * cos(p);
  33. yCoord = 5 * sin(p);
  34. }
  35. //Overloaded Funcion circle / Funcion circulo sobre cargada
  36. // YOUR CODE HERE / TU CODIGO AQUI
  37. ///************************************
  38. ///Function butterfly *
  39. ///************************************
  40. // YOUR CODE HERE / TU CODIGO AQUI
  41. //***************
  42. // Function main *
  43. //***************
  44. int main(int argc, char *argv[])
  45. {
  46. QApplication a(argc, argv);
  47. XYPlotWindow wCircleR5;
  48. XYPlotWindow wCircle;
  49. XYPlotWindow wButterfly;
  50. double r;
  51. double y = 0.00;
  52. double x = 0.00;
  53. double increment = 0.01;
  54. int argValue=0, argRef=0;
  55. // invoke the function illustration to view the contents of variables by value and by reference
  56. // invoca la funcion ilustracion para ver los contenidos de variables por valor y por referencia
  57. illustration(argValue,argRef);
  58. cout << endl << "The content of argValue is: " << argValue << endl
  59. << "The content of argRef is: " << argRef << endl;
  60. // repeat for several values of the angle t
  61. // repite para varios valores de el angulo t
  62. for (double t = 0; t < 16*M_PI; t = t + increment)
  63. {
  64. // invoke circle with the angle t and reference variables x, y as arguments
  65. // invke circle con el angulo t y variables por referencia x, y como argumentos
  66. circle(t,x,y);
  67. // add the point (x,y) to the graph of the circle
  68. // anade el punto (x,y) a la grafica de el circulo
  69. wCircleR5.AddPointToGraph(x,y);
  70. // invoke circle with the radius r, the angle t and reference variables x, y as arguments
  71. // invoca circulo con el radio r, el angulo t y variables x, y como argumentos
  72. // YOUR CODE HERE / TU CODIGO AQUI
  73. // add the point (x,y) to the graph of the circle
  74. // anade el punto (x,y) to la grafica de el circulo
  75. // YOUR CODE HERE / TU CODIGO AQUI
  76. // invoke butterfly with the angle t and reference variables x, y as arguments
  77. // invoca butterfly con el angulo t y variables referencia x, y como argumentos
  78. // YOUR CODE HERE / TU CODIGO AQUI
  79. // add the point (x,y) to the graph of the butterfly
  80. // anade el punto (x,y) a la grafica de la mariposa
  81. // YOUR CODE HERE / TU CODIGO AQUI
  82. }
  83. // After all the points have been added, plot and show the graphs
  84. // Despues que todos los puntos sean anadidos, enseña las graficas.
  85. wCircleR5.Plot();
  86. wCircleR5.show();
  87. // YOUR CODE HERE / TU CODIGO AQUI.
  88. return a.exec();
  89. }