week 10 module
Write a Swift playground program for three classes – a ‘Quadrilateral’, a ‘Parallelogram’ and a ‘Rectangle’ class – such that:
- The ‘Quadrilateral’ is the base parent class and has four attributes for its four sides.
- The ‘Parallelogram’ extends the ‘Quadrilateral’ class where two sets of sides are parallel to each other.
- The ‘Rectangle’ extends the ‘Parallelogram’ where two adjacent sides are at right angles to each other.
- You will need to define attributes for side lengths and angles to appropriately create each type of object.
- Quadrilateral needs 4 sides and 1 angle
- Parallelogram needs 2 sides and 1 angle
- Rectangle needs 2 sides and 1 angle which is 90 degrees
- This site is helpful in figuring out how to construct the shapes – http://www.ambrsoft.com/TrigoCalc/Quadrilateral/Shape1.htm
- The sum of the four angles has to equal 360 degrees.
- You may also need computed properties for area, perimeter and diagonals.
- Demonstrate inheritance and polymorphism as applied to this set of classes. Assume any other properties or methods that may be useful to you in completing this assignment.
- Document your code, please.
- Also put comments in code where necessary to make it more descriptive
- Format your console output in a clear to understand manner.
Upload your playground and a screenshot of the console window.