I have this code block which requires a main method in order to be run.
public class Point {
private int xcoord;
private int ycoord;
public Point () {}
public Point (int x, int y) {}
public int getX () {
return xcoord;
}
public int getY () {
return ycoord;
}
public void moveUp(int amount) {}
public void moveDown(int amount) {}
public void moveRight(int amount) {}
public void moveLeft(int amount) {}
}
I've tried adding in public static void main(String[] args){
below public class Point
but it causes problems throughout my program (saying Public Point () needs to be declared as new) and I close out the main method beneath the MoveLeft
method closing colon and the public class
Point closing colon, like this:
public class Point {
private int xcoord;
private int ycoord;
public static void main(String[] args){
public Point () {}
public Point (int x, int y) {}
public int getX () {
return xcoord;
}
public int getY () {
return ycoord;
}
public void moveUp(int amount) {}
public void moveDown(int amount) {}
public void moveRight(int amount) {}
public void moveLeft(int amount) {}
}
}
Main is a method and you don't want your other methods to be inside of it.
Try something like this:
public class Point {
private int xcoord;
private int ycoord;
public static void main(String[] args) {
} //End of main
//Now you add the rest of your methods
public Point(){
}
//And so on