Question: 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,

 a) Write a Java class called Point2D that can be usedto store two-dimensional points in coordinate geometry. This class has two int

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!