Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

This is my second program in the java realm of programming.

This is my second program in the java realm of programming. I was

able to write up the “polygon” file and it is able to compile. “TestPolygon” I found on this site and tried to modify it to be able to run. Something is not executing properly. The “TestPolygon” file should be separate from the “Polygon” file? Or should one be copied into another for it to run properly? Please advise and touch on the “TestPolygon” program. Thank you!

/*****/public class Polygon {private int numSides;//number of sidesprivate double sideLength; //length of each sideprivate double xCoord;//x-coordinate of th center of the polygonprivate double yCoord;//the y-coordinateprivate double apothem;//defines the apothemprivate double perimeter;// no argument constructorpublic Polygon() {this.numSides = 4;this.sideLength = 2.0;this.xCoord = 0.0;this.yCoord = 0.0;this.apothem = 4.0;this.perimeter = 16.0;}public Polygon(int _numSides, double _sideLength, double _xCoord, double_yCoord, double _apothem) {this.numSides = _numSides;this.sideLength = _sideLength;this.xCoord = _xCoord;this.yCoord = _yCoord;this.apothem = _apothem;}// area is doubledpublic double getArea() {perimeter = numSides * sideLength;double area = (0.5) * apothem * perimeter;return area;}//getter & setterspublic int getNumSides() {return numSides;}public void setNumSides(int numSides) {this.numSides = numSides;}public double getSideLength() {return sideLength;}public void setSideLength(double sideLength) {this.sideLength = sideLength;}
Background image of page 1
public double getxCoord() {return xCoord;}public void setxCoord(double xCoord) {this.xCoord = xCoord;}public double getyCoord() {return yCoord;}public void setyCoord(double yCoord) {this.yCoord = yCoord;}public double getApothem() {return apothem;}public void setApothem(double apothem) {this.apothem = apothem;}public double getPerimeter() {return perimeter;}public void setPerimeter(double perimeter) {this.perimeter = perimeter;}public String toString() {return “Polygon definitions[” + “number of sides=” + numSides + “, Eachside length=” + sideLength + “, xCoord=” + xCoord + “, yCoord=” + yCoord + “,apothem=” + apothem + ‘]’;}}
Background image of page 2
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"