Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: dont know whats wrong, robot project

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Thanked 0 Times in 0 Posts

    Question dont know whats wrong, robot project

    I get error Main method not found in class robot.Robot, please define the main method as: public static void main(String[] args). Can someone help me fix this error? Heres what I am trying to do:

    Implement a class Robot that simulates a robot wandering randomly on an infinite plane. The robot is located at a point with integer coordinates and faces north, east, south, or west. Supply Methods:

    public void turnLeft()
    public void turnRight()
    public void move()
    public Point getLocation()
    public String getDirection()

    The turnLeft and turnRight methods change the direction but not the location. The move method moves the robot by one unit in the direction it is facing. The getDirection method returns a string "N", "E'', "S", or "W".

    package robot;
    import java.awt.Point;
    import java.util.Random;
    public class Robot {
        // TODO: define other instance variables
        private int posX;
        private int posY;
        private final int orgX;
        private final int orgY;
        private final Random generator;
         * Constructor for objects of class Robot
         * @param theX the x coordinate
         * @param theY the y coordinate
        public Robot(int theX, int theY) {
            // TODO: Complete the constructor
            posX = theX;
            posY = theY;
            orgX = theX;
            orgY = theY;
            generator = new Random();
            generator.setSeed(12345);  //do not change this statement
        // TODO Supply getLocation
        public Point getLocation() {
            //return null;
            return new Point(posX, posY);
        // TODO: Supply the methods of the Robot class
        public double getDistanceFromStart() {
            return Math.sqrt(Math.pow(posX - orgX, 2) + Math.pow(posY - orgY, 2));
        public void makeRandomMove() {
            int move = generator.nextInt(4);
            if (move == 0) {
            } else if (move == 1) {
            } else if (move == 2) {
            } else {

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,710 Times in 2,660 Posts

    Default Re: dont know whats wrong, robot project

    please define the main method as: public static void main(String[] args).
    The error message has a good description of the definition for the main() method. Did you try it?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. robot simulation project
    By soccerstar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 16th, 2014, 04:28 AM
  2. i dont understand whats wrong with my code, please fix it.
    By gvnvhri in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 26th, 2013, 04:32 AM
  3. I dont see anything wrong with this(simple beginner code)
    By Olympaphibian89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 26th, 2012, 03:11 PM
  4. Problem with import java.util.*; dont know whats wrong
    By TheLeader in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 3rd, 2012, 12:33 PM
  5. Dont know whats happening
    By JJTierney in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 4th, 2010, 12:50 PM

Tags for this Thread