cours0708/P5B/ruby/class_Heure.rb

42 lines
462 B
Ruby
Raw Normal View History

2008-11-25 21:11:16 +00:00
class Heure
def initialize(h = 0, m = 0, s = 0)
@heure = h
@minute = m
@seconde = s
end
def heure()
@heure
end
def minute()
@minute
end
def seconde()
@seconde
end
def heure=(h)
@heure = h
end
def minute=(m)
@minute = m
end
def seconde=(s)
@seconde = s
end
end
x = Heure.new(15,20)
puts "Heure : #{x.heure}"
puts "Minutes : #{x.minute}"
puts "Secondes : #{x.seconde}"
x.heure = 16
puts "Heure modifi<66>e : #{x.heure}"