I’m a beginner. Trying to create chinese zodiac. User enters the year
and it shows what year it is in chinese zodiac.
class Zodiac
class Config
@@actions=[0,1,2,3,4,5,6,7,8,9,10,11, ‘quit’]
def self.action; @@actions; end
end
attr_accessor
def launch!
introduction
result = nil
until result == :quit
action1 = get_action
action=calc(action1)
result = do_action(action)
end
conclusion
end
def introduction
puts “Welcome!”
end
def conclusion
puts “Bye bye!!!”
end
def get_action
response = nil
puts “In what year were you born?”
print “>”
user = gets.chomp
return response
end
def calc (action)
calculate = (action - 5) % 12
return calculate
end
def do_action(action)
case action
when ‘0’
puts “Your chinese zodiac is ‘RAT’”
when 1
puts “Your chinese zodiac is ‘Ox’”
when 2
puts “Your chinese zodiac is ‘Tiger’”
when 3
puts “Your chinese zodiac is ‘Rabbit’”
when 4
puts “Your chinese zodiac is ‘Dragon’”
when 5
puts “Your chinese zodiac is ‘Snake’”
when 6
puts “Your chinese zodiac is ‘Horse’”
when 7
puts “Your chinese zodiac is ‘Sheep’”
when 8
puts “Your chinese zodiac is ‘Monkey’”
when 9
puts “Your chinese zodiac is ‘Rooster’”
when 10
puts “Your chinese zodiac is ‘Dog’”
when 11
puts “Your chinese zodiac is ‘Pig’”
when ‘quit’
return :quit
end
end
end
zodiac=Zodiac.new
zodiac.launch!