Last active
April 11, 2016 17:06
-
-
Save bendavis78/d5b5f03d941100f62e445ff7e168d252 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 :first_name, :last_name, :gender, :age | |
def initialize(first_name, last_name, gender, age) | |
@first_name = first_name | |
@last_name = last_name | |
@gender = gender | |
@age = age | |
end | |
def introduction | |
puts "#{@first_name} #{@last_name} is a #{@age} year old #{@gender}" | |
end | |
end | |
class Student < Person | |
def action | |
puts "#{@first_name} is learning" | |
end | |
end | |
class Teacher < Person | |
def action | |
puts "#{@first_name} is teaching" | |
end | |
end | |
p = Teacher.new "Ben", "Davis", "male", 37 | |
s = Student.new "John", "Doe", "male", 15 | |
people = [p, s] | |
people.each do |person| | |
person.introduction | |
person.action | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment