Question: Please write comments (in Java) Question #1 (Geometry: n-sided regular polygon) An n-sided regular polygon has n sides of the sane length and all angles
Question #1 (Geometry: n-sided regular polygon) An n-sided regular polygon has n sides of the sane length and all angles have the sane degree (.e., the polygon is both equilateral and equiangular). Deaign a 50 points class named RegularPolygon that contains: . A private int data field naned a that detines the number ot sides in the polygon with default value 3 A private double data field naned side that stores the length of the side with detault value i with default value g with default value g . A private double data tield naned x that detines the x-coordinate of the center ot the polygon A private double data tield named y that defines the y-coordinate of the center ot the polygon . A no-arg constructor that creates a regular polygon with default values . conat ructor that createn a regular polygon with the speci ' A constructor that creates a regular polygon with the specified mumber of sides, the length of . The accessor and mutator methods for all data fields. itied number of sides and the length of side, and centered at ( side, and x-and y-coordinates The nethod getPerimter) that returns the perimeter of the polygon. The perineter is the addition of the length of all the sides of the polygon. The method getareal) that returns the area of the polygon. The formula for eosputing the area n of a regular polygon is Area -. Use the Math. tan (double) nethod which also returns a 4xtan(*) double 25 points Question #2 Create a testing class which will create two RegularPolygon objects and is the two objects are the same display then display a message stating both objects contain the sane information. it objects are not the same then copy all the information from the second object into the first one Do not assign the objects. You need to copy all the infornation from second object into the tirst You will need to create two more methods in the RegularPolygon class: equals checks if the information of two objects are the same copy copies the information of one object into another Question #3 25 points Create a testing clasa which will create 5 RegularPolygon objecta. Set the side with a random number from 2 to 10 and set n with a randon number from 3 to 8. Display the following for each polygon: . Perineter e Area .Type of Polygor Type Polygon is based on the number of sides Sides Type Triangle Quadrilateral Pentagon Hexagor tagon Octagon
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
