Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Write a Java class called Point2D that can be used to store two-dimensional points in coordinate geometry. This class has two int instance variables,

image text in transcribedimage text in transcribed

a) Write a Java class called Point2D that can be used to store two-dimensional points in coordinate geometry. This class has two int instance variables, x and y. Provide the following functionality: i. A two parameter constructor that initializes the instance variables, in the order x and y. ii.Accessors for the instance variables. A method public String toString() that returns a String representation of The standard equals method that compares two Point2D objects for equality. b) In a n-sided regular polygon, all sides have the same length and all angles have the same An int instance variable n that defines the number of sides in the polygon, with ii.A double instance variable side that stores the length of the side with default iii. the point in the format . iv. degree. Write a Java class called RegularPolygon that contains: i. a default value of 3. value 1. A Point2D instance variable center that stores the x and y coordinates of the polygon's center, with default values 0 for both the x and y components of the Point2D object. Ano argument constructor that creates a regular polygon with default values A constructor that creates a regular polygon with the specified number of sides, length of side, and a Point2D object that represents the center of the polygon, in that order. iii. iv. v. vi.Accessors and mutators for all fields. vii. The instance method perimeter) that returns the perimeter of the polygon viii. The instance method area() that returns the area of the polygon. The formula for n x side2 computing the area of a regular polygon is area:- 4 x tan

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago