Skip to content

Instantly share code, notes, and snippets.

@joseluistorres
Created September 17, 2013 16:46
Show Gist options
  • Save joseluistorres/6597042 to your computer and use it in GitHub Desktop.
Save joseluistorres/6597042 to your computer and use it in GitHub Desktop.
Dependencias fixed
class Lluvia
def initialize(intensidad, granizo)
@intensidad = intensidad
@granizo = granizo
end
def empieza_lluvia
puts "=============LLUVIA=#{@intensidad}=========="
end
end
class Huracan
attr_readers :lluvia
def initialize(args)
@lat = args[:lat] || 20
@lon = args[:lon] || 30
@mucha_lluvia = args.fetch(:mucha_lluvia, false)
@derrumbes = args.fetch(:derrumbes, false)
@lluvia = args[:lluvia]
end
def empezar_desastre
lluvia.empieza_lluvia if @mucha_lluvia
end
end
Huracan.new(10,20, true, false, Lluvia.new(100, true)).empezar_desastre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment