Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include Math
- #modül Ucgeni farklı bi dosyaya al require et
- #aynı dizindeki dosyaları require etmek için $LOAD_PATH.unshift File.join(File.dirname(__FILE__))
- # kullan
- module Ucgen
- def cevre
- @cevre = @x + @y + @z
- end
- end
- class Ikizkenar
- include Ucgen
- def initialize(x,y,z)
- if x==y || x==z || y==z
- @x,@y,@z = x,y,z
- else
- raise ArgumentError, 'Argument is not numeric' unless x==y || x==z || y==z # raise kullanımını öğren düzelt *
- end
- end
- def alan
- if @x==@y
- @alan= (@z*sqrt(@x**2 - (@z/2)**2))/2
- elsif @x==@z
- @alan= (@y*sqrt(@x**2 - (@y/2)**2))/2
- else
- @alan= (@x*sqrt(@x**2 - (@x/2)**2))/2
- end
- end
- end
- class Eskenar
- include Ucgen
- def initialize(x,y,z)
- if x==y && x==z
- @x,@y,@z = x,y,z
- else
- raise 'bu bir ikizkenar değil'
- end
- end
- def alan
- @alan=@x*@x* sqrt(3)/2
- end
- end
- a = Ikizkenar.new 6,5,5
- puts a.cevre
- puts a.alan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement