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
When I use the command prompt to run this file it does compile, then when I try to run the program it gives me an error. Error: Main method not found in class Polygon, please define the main method as:
  public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Â
Â
How do I fix this, because when I add the main method, it will not compile.
Â
Â
/**
* 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 + ")";
}
}
-----------