Software Construction Assignment: Assignment 2 (Worth 200 Points)
Assignment #2
Total Points: 200
Use an object-oriented language (Java, C#, or C++) to solve the following problems.
• Write a pair of classes, Square1 and Rectangle1. Define Square1 as a subclass of Rectangle1. In addition to setters and getters, provide such methods as computeArea and computePerimeter. Specify the preconditions, postconditions and class invariants, if any, as comments (30%)
• Write a pair of classes, Square2 and Rectangle2. Define Rectangle2 as a subclass of Square2. In addition to setters and getters, provide such methods as computeArea and computePerimeter. Specify the preconditions, postconditions and class invariants, if any, as comments (30%)
• Compare (1) and (2), illustrating the pros and cons of (1) and (2), respectively.
(40%)
For (1) and (2), copy and paste source code and running results (you need to write test programs). For (3), you should type and print your answer. Your answer should be detailed and argued based on design principles such as OCP, LSP and others.