Skip to content

Instantly share code, notes, and snippets.

@blackknight36
Created February 28, 2017 21:55
Show Gist options
  • Save blackknight36/3fbb9644c7c340826b846a69945f0224 to your computer and use it in GitHub Desktop.
Save blackknight36/3fbb9644c7c340826b846a69945f0224 to your computer and use it in GitHub Desktop.
class Person
attr_accessor :age
def initialize(initialAge)
@age = initialAge
if @age < 0 then
puts "Age is not valid, setting age to 0."
@age = 0
elsif @age > 30 then
puts "You are too old!"
end
end
def amIOld()
# Do some computations in here and print out the correct statement to the console
if @age < 13
puts "You are young."
elsif @age.between?(13, 17)
puts "You are a teenager."
else
puts "You are old."
end
end
def yearPasses()
# Increment the age of the person in here
@age += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment