class Score
def initialize(subject, score)
@subject = subject
@score = score
end
def get_info
"#{@subject}/#{@score} -> #{get_result}"
end
private
def get_result
@score >= 80 ? "Pass" : "Fail"
end
end
class MathScore < Score
def initialize(score)
super("Math", score)
end
end
class EnglishScore < Score
def initialize(score)
super("English", score)
end
end
class User
def initialize(name, score)
@name = name
@score = score
end
def get_info
"Name: #{@name}, Score: #{@score.get_info}"
end
end
user1 = User.new("Taro", MathScore.new(70))
user2 = User.new("Jiro", EnglishScore.new(90))
puts user1.get_info
puts user2.get_info