Created
October 11, 2013 16:04
-
-
Save TrevMcKendrick/6937420 to your computer and use it in GitHub Desktop.
This file contains 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 School | |
attr_accessor :name, :roster | |
def initialize(name) | |
@roster = {} | |
@name = name | |
end | |
def add_student(student_name, grade) | |
self.roster[grade] ||= [] | |
self.roster[grade] << student_name | |
end | |
def grade(grade) | |
self.roster[grade] | |
end | |
def sort | |
self.roster.each do |key,value| | |
value.sort! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment