Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Here is my pull request #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
58 changes: 58 additions & 0 deletions Student.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
class Student

#Getter
attr_reader :first_name,:last_name

#Contractor
def initialize(first_name,last_name,grade)
@first_name = first_name
@last_name = last_name
@grade = grade
end

#method for output
def to_s
"#{last_name} , #{first_name}"
end

def senior?
grade == 12
end

def juniors?
grade == 11
end
end # end of student class


#def seniors(students)
# senior_students = [] #empty array
#students.each do |student|
# if student.grade == 12
# senior_students.push(students) #add to senior student array
#end
#end
# return senior_students
#end

#better
def senior(students)
students.select {|student| student.senior? }
end

#Creating Student Object

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

#Arry of All Student
all_students = [fred,sarah,jack]

puts all_students
#=end

seniors(all_students).each do |student|
puts student
end

10 changes: 10 additions & 0 deletions clone_war.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CloneWar

def war?
false
end

end

cw = CloneWar.new()
puts