Created
May 29, 2013 05:58
-
-
Save markson/5668240 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 :name, :gender, :height, :weight | |
def initialize(name, gender, height, weight) | |
@name = name | |
@gender = gender | |
@height = height | |
@weight = weight | |
end | |
def cry | |
"woooo" | |
end | |
end | |
class Student < Person | |
attr_accessor :student_id | |
def initialize(name, gender, height, weight, student_id) | |
super(name, gender, height, weight) | |
@student_id = student_id | |
end | |
def study | |
"Student #{name} with #{student_id} is studying now" | |
end | |
end | |
s = Student.new("Lin", "Male", 173, 75, 666777) | |
puts s.cry() | |
puts s.study |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment