Last active
December 16, 2015 06:28
-
-
Save gregory/5391286 to your computer and use it in GitHub Desktop.
jsut simpel example for POO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cirle < Form | |
attr_reader :rayon | |
def initializer(rayon) | |
@rayon = rayon | |
end | |
#Circle.area(20) => 200 | |
def self.area(rayon) | |
Math.Pi * rayon**2 | |
end | |
#Cicle.pring_area(20) => "Ma super surface est de: 200" | |
def self.pring_area(rayon) | |
puts "Ma super surface est de: #{self.area(rayon)}" | |
end | |
#Cicle.pring_area_with_instance(20) => "Ma super surface est de: 200" | |
def self.pring_area_with_instance(rayon) | |
mon_cirle = Circle.new(20) | |
puts "Ma super surface est de: #{mon_cirle.area}" | |
end | |
#mon_cercle = Circle.new(20); mon_cercle.rayon => 20; mon_cercle.area => 200 | |
def area | |
Circle.area(self.reayon) | |
end | |
#mon_volume = Circle.new(20); mon_cercle.rayon => 20; mon_cercle.area => 200; mon_cercle.volume => 4000 | |
def volume | |
4/3 * self.area * self.rayon | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form | |
def color | |
end | |
def area | |
end | |
def volume | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Square < Forme | |
def self.area(length) | |
end | |
def area | |
end | |
def volume | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment