[Solved] SOLVED: Design a Java class named polygon and test polygon

$25

File Name: SOLVED:_Design_a_Java_class_named_polygon_and_test_polygon.zip
File Size: 546.36 KB

SKU: [Solved] SOLVED: Design a Java class named polygon and test polygon Category: Tag:
5/5 - (1 vote)

private double data field named yCoord that defines the y-coordinate of the center of the polygon. The default value should be 0.0. A no argument constructor that creates a Polygon using the default number of sides, default side length and default x- and y-coordinates. A constructor that creates a Polygon using a specified number of sides, side length and x- and y-coordinates. Getter and setter methods for all data fields A getPerimeter() method that returns a double value representing the sum of all sides. A toString() method that displays the number of sides, side length, x-coordinate and ycoordinate values in String format. Be sure your code compiles. (In the next question, you will create a TestPolygon class and test each of the methods) Write a Java test program, named TestPolygon, to create five different polygons. When creating the five polygons, create one using the no argument constructor. For the remaining four, feel free to use any number of sides, side length and x-, and y-coordinates that are not equal to the default values and not equal to each other. For each of the five polygons, call all of the methods and display the results. For example for a Polygon with 3 sides, side length of 2.0 and x-coordinate and ycoordinates of 1.0, the following output may be appropriate. toString() results: (3, 2.0, 1.0,1.0) getNumSides() results: 3 getSideLength() results: 2.0 getXCoord() results: 0.0 getYCoord() results: 0.0 getPerimeter() results: 6.0 setNumSides(4) results: 4 setSideLength(3) results: 3.0 setXCoord(2.0) results: 2.0 setYCoord(2.0) results: 2.0 Keep in mind, for five Polygons, you will have five different output results. Also, note there is no requirement to actually draw a Polygon. Submission requirements:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED: Design a Java class named polygon and test polygon
$25