The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hi Chacheji,Â
I have stumbled on one of your answers, but when I compile and run on Dr. Java it says:Â
Static Error: This class does not have a static void main method accepting String[].
Would you know why it is saying that?
Â
Polygon.java
/**
* Polygon Class
*/
public class Polygon {
private int numSides;
private double sideLength;
private double xCoord;
private double yCoord;
private double apothem;
public double perimeter;
/**
* constructor with no argument
*/
public Polygon() {
numSides = 4;
sideLength = 5.0;
xCoord = 0.0;
yCoord = 0.0;
apothem = 5.0;
perimeter = 20.0;
}
/**
* constructor with parameters
*/
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;
}
// getters and setters
public int getnumSides() {
return this.numSides;
}
public void setnumSide(int numSides) {
this.numSides = numSides;
}
public double getsideLength() {
return this.sideLength;
}
public void setsideLength(double sideLength) {
this.sideLength = sideLength;
}
public double getxCoord() {
return this.xCoord;
}
public void setxCoord(double xCoord) {
this.xCoord = xCoord;
}
public double getyCoord() {
return this.yCoord; }
public void setyCoord(double yCoord) {
this.yCoord = yCoord;
}
public double getApothem() {
return this.apothem;
}
public void setApothem(double apothem) {
this.apothem = apothem;
}
public double getperimeter() {
return this.numSides * this.sideLength;
}
public double getArea() {
return 0.5 * apothem * getperimeter();
}
// returns string form of polygon
public String toString() {
return "(numsides=" + numSides + ", sideLength=" + sideLength + ", xcoord=" +
xCoord + ", ycoord=" + yCoord
+ ", apothem=" + apothem + ")";
}
}