34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
/**
|
|
* Answers the question.
|
|
*
|
|
* Question3:
|
|
*
|
|
* - Q: What is the problem with the resize method of the Shape calss? How do
|
|
* you solve this problem?
|
|
*
|
|
* - A: The resize method of the Dot class is inherited from the Shape class.
|
|
* which does not have a throw Exception declared. We can solve this problem by
|
|
* declaring the resize method in the Shape class as a throw Exception.
|
|
*
|
|
* - Q: Do you need to change the resize method of the Circle class then?
|
|
*
|
|
* - A: No, we do not need to change the resize method of the Circle class.
|
|
*
|
|
* - Q: Does the Square class need its own area and resize method or not?
|
|
*
|
|
* - A: No, but it depends. Currently the Square.area and Square.resize methods
|
|
* return the correct values. But in the future, if we want to change the
|
|
* Rectangle.area and Rectangle.resize methods, the Square class may give the
|
|
* wrong values. So it is better to have its own area and resize methods.
|
|
*/
|
|
|
|
public class Start {
|
|
public static void main(String[] args) {
|
|
Shape.testShape();
|
|
Circle.testCircle();
|
|
Dot.testDot();
|
|
Rectangle.testRectangle();
|
|
Square.testSquare();
|
|
}
|
|
}
|