Created
February 28, 2017 21:55
-
-
Save blackknight36/3fbb9644c7c340826b846a69945f0224 to your computer and use it in GitHub Desktop.
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 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