Ellipse program:
Java’s API classes make extensive use of inheritance. For example, Oracle’s Java API documentation shows that the
java.awt.geom.Ellipse2Dpackage has a class named
Doublethat has these instance variables:6
double | heightThe overall height of the Ellipse2D. |
double | widthThe overall width of this Ellipse2D. |
double | xThe x-coordinate of the upper-left corner of this Ellipse2D. |
double | yThe y-coordinate of the upper-left corner of this Ellipse2D. |
And it has these constructors:
Double() Constructs a new Ellipse2D,initialized to location (0, 0). and size (0, 0). |
Double( double x, double y, double w, double h) Constructs and initializes an Ellipse2Dfrom the specified coordinates. |
It has accessors for the instance variables, and an initializing method, but that’s about all. Fortunately, this class
extendsa class called
Ellipse2D,which has several other useful methods, including:
boolean | contains ( double x, double y) Tests if a specified point is inside the boundary of this Ellipse2D. |
boolean | contains (double x, double y, double w, double h) Tests if the interior of this Ellipse2D entirely contains the specified rectangular area. |
boolean | intersects ( double x, double y, double w, double h) Tests if the interior of this Ellipse2Dintersects the interior of a specified rectangular area. |
Write a short program in a class called
EllipseDriver:
Import
java.awt.geom.Ellipse2D.Double,and write a
mainmethod that calls the 4-parameter
Doubleconstructor to instantiate an ellipse like that shown in the picture below.7 Then, in
printlnstatements, call the superclass’s 2-parameter
containsmethod to show whether the points x=3.5, y=2.5 and x=4.0, y=3.0 are contained within the specified ellipse.

Output:
contains x=3.5, y=2.5? falsecontains x=4.0, y=3.0? true
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.