Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The oval subclass does not want to provide either the SetAngle1 or SetAngle2 methods because it is a closed arc. The circle subclass additionally wants
The oval subclass does not want to provide either the SetAngle1 or SetAngle2 methods because it is a closed arc. The circle subclass additionally wants to eliminate the setWidth and setHeight methods and add a setDiameter method. Answer the following questions:
- What is the problem with the class hierarchy?
- Suggest another way to implement the oval and circle subclasses that allows you to "inherit" the implementation of the arc subclass without incurring the disadvantages of actual inheritance. Sketch out a sample Java class declaration for a circle that includes the following elements:
- declarations for the instance variable(s)
- declarations for the public methods (it is okay to use my "some parameters" notation for the parameters to the Draw method)
- implementations for the setLeft and setDiameter methods.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started