Computers and Technology

Task: 1. Define a class named Circle.
2. A Circle object stores a radius and the (x, y) coordinates of its center point using Point class (Point class should be similar to the one we wrote during lectures. It should have at least two private fields to store x and y coordinates of a point, one constructor, a toString method and a distance method).
3. Each Circle object should have 2 private fields, a Point object and radius. Each Circle Object should have the following public method:
Circle (p-radius)
Constructs a new circle with a center specified by the given Point p and with the given integer radius.
getcentert ()
Returns point object for the center of the circle.
getRadius ()
Returns the circle's radius.
getArea ()
Returns the area occupied by the circle, using the formula pir2.
get circumference ()
Returns the circle's circumference (distance around the circle), using the formula 2nr.
teostring ()
Returns a string representation of the circle, such as "Circle [center=(75, 20), radius=30]".
contains (p)
Returns true if the point p lies within the circle else returns false. (Hint: calculate the distance between the center and the point p and compare it with the radius).
Write a client class named CircleClient. It should create an object of class Circle and initialize it to point (10,5) and radius 7. Print the object. Print out its circumference and area. If point (5,7) lies within the circle print "(5,7) lies within the circle" else print "(5,7) does not lie within the circle".

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:00, breella0
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, nika0001
When designing content as part of your content marketing strategy, what does the "think" stage represent in the "see, think, do, care" framework?
Answers: 3
image
Computers and Technology, 23.06.2019 09:10, babyskitt
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, soapai
Select the correct answer. sean is a computer programmer. he has programmed an application for toddlers that plays nursery rhymes. however, a logic error has occurred in the program. which problem is a likely consequence of the error? a. the program crashes every time the user wants to play the nursery rhymes. b. the program crosses its buffer boundaries and overwrites an adjacent program. c. the program plays a different nursery rhyme than the one the user intended to play. d. the program shows different structures in its programming language code. e. the program introduces new viruses every time the user plays a nursery rhyme.
Answers: 1
Do you know the correct answer?
Task: 1. Define a class named Circle.
2. A Circle object stores a radius and the (x, y) coord...

Questions in other subjects:

Konu
Mathematics, 27.09.2019 09:00