/student.rb Secret
Last active
March 31, 2023 01:10
-
Star
(0)
You must be signed in to star a gist -
Fork
(702)
You must be signed in to fork a gist
-
-
Save dbc-challenges/11a2f7ef313ed37fc569 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student | |
attr_accessor :scores, :first_name | |
def initialize(args) #Use named arguments! | |
#your code here | |
end | |
end | |
## ADD YOUR CODE HERE and IN THE CLASS ABOVE | |
#1. Create an array of 5 Students each with 5 test scores between 0 and 100. | |
# The first Student should be named "Alex" with scores [100,100,100,0,100] | |
#2. Add average and letter_grade methods to the Student class. | |
#3. Write a linear_search method that searches the student array for a student name | |
# and returns the position of that student if they are in the array. | |
#===========DRIVER CODE : DO NOT MODIFY ======= | |
#Make sure these tests pass | |
# Tests for part 1: | |
p students[0].first_name == "Alex" | |
p students[0].scores.length == 5 | |
p students[0].scores[0] == students[0].scores[4] | |
p students[0].scores[3] == 0 | |
# Tests for part 2 | |
p students[0].average == 80 | |
p students[0].letter_grade == 'B' | |
# Tests for part 3 | |
p linear_search(students, "Alex") == 0 | |
p linear_search(students, "NOT A STUDENT") == -1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment