Advertisement
Guest User

Untitled

a guest
Feb 28th, 2009
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. # XQYZi - Math Class
  2. # Containes useful functions regarding the calculations of different things
  3. # (hell, worst description ever)
  4. #
  5. # Copyright (C) 2009 Patrick Lerner [[email protected]]
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20.  
  21. class Math
  22. {
  23. function Sqr ( num )
  24. {
  25. return ( * ( num num ) )
  26. }
  27.  
  28. function Sqrt ( num )
  29. {
  30. return ( ^ ( num 0.5 ) )
  31. }
  32.  
  33. function Pi ( )
  34. {
  35. return ( 3.141592653589793238 )
  36. }
  37.  
  38. class Circle
  39. {
  40. function Area ( r )
  41. {
  42. return ( * ( Math.Pi ( ) Math.Sqr ( r ) ) )
  43. }
  44.  
  45. function Circumference ( r )
  46. {
  47. return ( * ( 2 Math.Pi ( ) r ) )
  48. }
  49. }
  50.  
  51. class Rectangle
  52. {
  53. function Area ( a b )
  54. {
  55. return ( * ( a b ) )
  56. }
  57.  
  58. function Circumference ( a b )
  59. {
  60. return ( + ( a a b b ) )
  61. }
  62. }
  63.  
  64. class Square
  65. {
  66. function Area ( a )
  67. {
  68. return ( Math.Rectangle.Area ( a a ) )
  69. }
  70.  
  71. function Circumference ( a )
  72. {
  73. return ( Math.Rectangle.Circumference ( a a ) )
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement