# list0402.rb
# 単純継承の例
class Work
def initialize(author,title,date)
@author = author
@title = title
@date = date
end
def what
print "題目:", @title, "\n"
end
def whose
print "作者:", @author, "\n"
end
def when
print "日付:",@date,"\n"
end
end
class Paper < Work
def initialize(author,title,date,contents)
@author = author
@title = title
@date = date
@document = contents
end
def show
print "内容:",@document,"\n"
end
end
x = Paper.new('鳥大太郎','はじめてのRuby','2002.10.22','Hello World!')
x.what
x.whose
x.when
x.show