You just learned how to avoid repeating yourself by using class inheritance. Now you've been tasked with putting that knowledge to use.
- Within
~/dev/wdi/godot/w02/d04/student/wdi_the_program/, create a file calledstudent.rb - Within
student.rb, define a barebonesStudentclass and make it inherit the behaviors of theHumanclass - In
main.rb, userequire_relativeto bring in the code fromstudent.rb
- Note: Make sure you require the
student.rbfile after you've requiredhuman.rb, because the former is going to rely on the class definition in the latter.
- Great, now instantiate a student object in
main.rband assign it to a sensibly-named variable. Then use some of the behaviors your student inherited from theHumanclass (for example,speakandshout) to make sure it worked.
- Don't move on until
Humanbehaviors work for your student object.
- Upon instantiation, give every
Studentan attribute calledhomeworksassigned to an empty array.
- provide a getter for
homeworks
- Provide instances of the
Studentclass with the ability todo_homework.do_homeworkshould take a single argument and push whatever gets passed in as an argument into the student'shomeworksarray.