11/30/21, 10:28 PM Homework 4
https://canvas.vt.edu/courses/135925/assignments/1337997 1/3
Homework 4
12/6/2021
100 Possible Points
IN PROGRESS
Next Up: Submit Assignment
Unlimited Attempts Allowed
Attempt 1 Add Comment
Details
Homework 4
We are going to implement a small class hierarchy in Ruby. We are going to do a classic shape
hierarchy with a base class, 3 subclasses, and then 1 subclass from there.
Details
Most of what is needed will be detailed in the API
(https://canvas.vt.edu/courses/135925/file_contents/course%20files/Project_Files/HW4/doc/index.html) .
All of the required classes along with their required methods are listed.
In Ruby, when a class subclasses another class that is shown using the < symbol. For example class Shape end class Circle < Shape end means that we have a class Shape and that the class Circle is subclassing the class Shape . Just like in Java, a subclass can override the parent’s methods and use them as well. Data that is stored in the base class is accessible to the subclass. Use of the keyword super will cause a child class to call the parent’s class method with the same name. Testing I have written a main that you should use to both implement all of your classes at the top and use for testing. The main will expect 2 commandline arguments, the input file and the output file. The input file will specify a series of shapes that you are to instantiate and then display using the pretty_shape method. You can use this main as a basis for the final project as well.Submit Assignment https://canvas.vt.edu/courses/135925/file_contents/course%20files/Project_Files/HW4/doc/index.html 11/30/21, 10:28 PM Homework 4 https://canvas.vt.edu/courses/135925/assignments/1337997 2/3 Choose a submission type Here is a sample input and output file Input square red 4.20 circle blue 3.5 rectangle green 6.9 4.20 triangle purple 4.5 6.8 Output Name: Square Color: red Side: 4.20 Area: 17.64 Name: Circle Color: blue Radius: 3.50 Area: 38.46 Name: Rectangle Color: green Width: 4.20 Height: 6.90 Area: 28.98 Name: Triangle Color: purple Base: 4.50 Height: 6.80 Area: 15.30 So you will be implementing the methods in your classes to allow for the calls in main to work correctly. Files main.rb (https://canvas.vt.edu/courses/135925/files/20965985?wrap=1) (https://canvas.vt.edu/courses/135925/files/20965985/download?download_frd=1) Upload More Canvas Files Choose a file to upload File permitted: RB Submit Assignment https://canvas.vt.edu/courses/135925/files/20965985?wrap=1 https://canvas.vt.edu/courses/135925/files/20965985/download?download_frd=1 11/30/21, 10:28 PM Homework 4 https://canvas.vt.edu/courses/135925/assignments/1337997 3/3