Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def initialize(first_name, last_name, grade)
@grade = grade
end

def junior?
grade == 11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should watch out for your indentions --- in Ruby, standard is 2 spaces for indentions. Here (and in juniors) is looks like a tab.

end

def senior?
grade == 12
end
Expand All @@ -20,11 +24,21 @@ def seniors(students)
students.select { |student| student.senior? }
end

def juniors(students)
students.select { |student| student.junior? }
end

fred = Student.new("Fred", "James", 12)
sarah = Student.new("Sarah", "Smith", 12)
jack = Student.new("Jack", "Gong", 11)
all_students = [fred, sarah, jack]

puts "Seniors"
seniors(all_students).each do |student|
puts student
print " * " , student , "\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool use of print here.

To get what you wants with "puts":

puts "*#{student}\n"

end

puts "\nJuniors"
juniors(all_students).each do |student|
print " * " , student, "\n"
end