Question: Use an object-oriented language (Java, C#, or C++) to solve the following problems. 1. Write a pair of classes, Square1 and Rectangle1. Define Square1 as
Use an object-oriented language (Java, C#, or C++) to solve the following problems.
1. 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
2. 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
3. Compare (1) and (2), illustrating the pros and cons of (1) and (2), respectively.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
