Skip to content

Instantly share code, notes, and snippets.

@epoch
Last active January 19, 2021 13:59
Show Gist options
  • Save epoch/f9d579199b3dc51f6df9 to your computer and use it in GitHub Desktop.
Save epoch/f9d579199b3dc51f6df9 to your computer and use it in GitHub Desktop.

Grade School

Write a small archiving program that stores students along with the grade that they are in.

This is meant to test your objects, class, hash & array knowledge. No actual database needed.

school = School.new("Haleakala Hippy School")

If no students have been added, the db should be empty:

school.db
# => {}

When you add a student, they get added to the correct grade.

school.add("James", 2)
school.db
# => {2 => ["James"]}

You can, of course, add several students to the same grade, and students to different grades.

school.add("Phil", 2)
school.add("Jennifer", 3)
school.add("Little Billy", 1)
school.db
# => {2 => ["James", "Phil"], 3 => ["Jennifer"], 1 => ["Little Billy"]}

Also, you can ask for all the students in a single grade:

school.grade(2)
# => ["James", "Blair"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment