HMWK3
Due: 19 April 2023, by end of class
Take some time to examine some of the Ruby resources I've provided on the web page!
NOTE!!!:
A) You may find that a _small_ extension to the class "Student" is required. Note what you had to do and why on your submission.
B) Please include a screenshot of a run of your code with the output. So the grader has some notion of how you expected it to work.
1) Write a Ruby function which takes a list of strings, ignores the first three and then returns the string which is shortest in length.
2) Write a Ruby function which takes a single string and returns a new string with only every third character.
func("abcdef") => "ad"
func("hhiijjkk") => "hik"
3) The following class definition is provided:
class Student
def initialize
@name = String.new()
@age = Integer
@id = Integer
@grade = Integer
end
def this?(id)
@id == id
end
def name()
@name
end
def name=(name)
@name=name
end
def age=(age)
@age=age
end
def id=(id)
@id = id
end
def grade()
@grade
end
def grade=(grade)
@grade=grade
end
end
Write a class which stores a collection of students.
It should implement the following four functions:
add(string,int,int,int) puts a new student record in the structure
find(int) returns the name (or error string) of the student with them matching id
top() returns the name of the student with the highest grade
median() returns the median age of the students