diff --git a/student.rb b/student.rb index 514cc09..df1e04c 100644 --- a/student.rb +++ b/student.rb @@ -11,6 +11,10 @@ def senior? grade == 12 end + def junior? + grade == 11 + end + def to_s "#{last_name}, #{first_name}" end @@ -20,11 +24,23 @@ 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 + puts " * " + student.to_s +end + +puts + +puts "Juniors" +juniors(all_students).each do |student| + puts " * " + student.to_s end