CircleProperties program: Javas API classes make extensive use of inheritance. For example, Oracles Java API documentation shows
Question:
CircleProperties program:
Java’s API classes make extensive use of inheritance. For example, Oracle’s Java API documentation shows that the javafx.scene.shape package has a class named Circle that is a child of a class named Shape, which is itself a child of a class named Node. Circle inherits more than 30 methods from its parent, Shape, and more than 330 methods from its grandparent, Node. One of Circle’s constructors has three double parameters, the first two for the x and y coordinates of its center and the third for its radius.
Implement a program that creates a circle centered at 50, 30 with a radius of 20. Have the program ask the user to supply an additional pair of x and y coordinate values. Use Node’s contains method to see if the point corresponding to these (other) user-entered x and y coordinates is within the circle. Also use Node’s intersects method to see if there is any overlap between the circle and a rectangle whose upper left corner is at the user- entered x and y coordinates and whose width and height are 20 and 15, respectively.
Step by Step Answer:
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean