Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. include Math
  2. #modül Ucgeni farklı bi dosyaya al require et
  3. #aynı dizindeki dosyaları require etmek için $LOAD_PATH.unshift File.join(File.dirname(__FILE__))
  4. # kullan
  5. module Ucgen
  6. def cevre
  7. @cevre = @x + @y + @z
  8. end
  9.  
  10. end
  11. class Ikizkenar
  12. include Ucgen
  13.  
  14. def initialize(x,y,z)
  15. if x==y || x==z || y==z
  16. @x,@y,@z = x,y,z
  17. else
  18. raise ArgumentError, 'Argument is not numeric' unless x==y || x==z || y==z # raise kullanımını öğren düzelt *
  19. end
  20. end
  21. def alan
  22. if @x==@y
  23. @alan= (@z*sqrt(@x**2 - (@z/2)**2))/2
  24. elsif @x==@z
  25. @alan= (@y*sqrt(@x**2 - (@y/2)**2))/2
  26. else
  27. @alan= (@x*sqrt(@x**2 - (@x/2)**2))/2
  28. end
  29. end
  30. end
  31. class Eskenar
  32. include Ucgen
  33. def initialize(x,y,z)
  34. if x==y && x==z
  35. @x,@y,@z = x,y,z
  36. else
  37. raise 'bu bir ikizkenar değil'
  38. end
  39. end
  40. def alan
  41. @alan=@x*@x* sqrt(3)/2
  42. end
  43. end
  44. a = Ikizkenar.new 6,5,5
  45. puts a.cevre
  46. puts a.alan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement