Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2015 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6bb34533ff9dae715823 to your computer and use it in GitHub Desktop.
Save anonymous/6bb34533ff9dae715823 to your computer and use it in GitHub Desktop.
class Grade
attr_accessor :assignment_name
attr_accessor :max_points
attr_accessor :points_received
#define initializer
def initialize(name, points, score = nil)
@assignment_name = name
@max_points = points
@points_received = score
end
#define method to format input
def to_s
points_received = @points_received || '--'
'%-15.15s' % @assignment_name + " : " + '%-2.2s' % @max_points + " " + '%-2.2s' % points_received
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment