/trunk/Examples/php/proxy/example.cxx

# · C++ · 43 lines · 31 code · 10 blank · 2 comment · 0 complexity · 432ee594f0afcaa370f863fe08d1f9d0 MD5 · raw file

  1. /* File : example.c */
  2. #include "example.h"
  3. #include <math.h>
  4. #ifndef M_PI
  5. # define M_PI 3.14159265358979323846
  6. #endif
  7. int Shape::get_nshapes() {
  8. return nshapes;
  9. }
  10. /* Move the shape to a new location */
  11. void Shape::move(double dx, double dy) {
  12. x += dx;
  13. y += dy;
  14. }
  15. int Shape::nshapes = 0;
  16. void Circle::set_radius( double r ) {
  17. radius = r;
  18. }
  19. double Circle::area(void) {
  20. return M_PI*radius*radius;
  21. }
  22. double Circle::perimeter(void) {
  23. return 2*M_PI*radius;
  24. }
  25. double Square::area(void) {
  26. return width*width;
  27. }
  28. double Square::perimeter(void) {
  29. return 4*width;
  30. }
  31. Circle *CircleFactory( double r ) {
  32. return new Circle(r);
  33. }