Obeezy
Obeezy

Reputation: 11

What does "<indentifier> expected" mean?

I am making Robot Soccer. I have 4 classes

Game is supposed to hold the main method, however this is what I have:

import java.util.*;

    public class Game{
        public Robot;
        public Ball;
        public Point;

        public static void main(String[]args){
           Point field= new Point();
           Point end = new Point();
           field.x=10;
           field.y=10;
           end.x=10;
           end.y=0;



        }

    }

For Point I have:

public class Point{
   public int x;
   public int y;
}

But in Ball and Robot I get an identifier error when I I set initial positions for the ball and robot objects: Ball:

public class  Ball{

    class Ball{
        Ball fifa= newBall();
        Point fifa= newPoint();
        int speed=1;
        fifa.x= 5;
        fifa.y= 5;
    }


    public void moveUp(){
        fifa.y=y-1;

    }
    public void moveDown(){
        fifa.y++;

    }
    public void moveLeft(){
        fifa.x--;


    }
    public void moveRight(){
        fifa.x++;
    }
}

Robot:

import java.util.*;

public class Robot{

   class Robot{

      Point d= newPoint();
      Point e= newPoint();
      Robot d= newRobot();
      Robot e= newRobot();
      int speed=1;
      d.x = 0;
      e.x =3;
      d.y = 1;
      e.y =5;
    }



    public void moveUp(){
        d.y=y-1;
        e.y=y-1;
    }
    public void moveDown(){
        d.y++;
        e.y++;
    }
    public void moveLeft(){
        d.x--;
        e.x--;

    }
    public void moveRight(){
        d.x++;
        e.x++;
    }
}

Why is this?

Upvotes: 0

Views: 137

Answers (1)

Prabhakaran Ramaswamy
Prabhakaran Ramaswamy

Reputation: 26094

You have not given the variable name for your objects.

change

    public Robot;
    public Ball;
    public Point;

to

    public Robot robot =null;
    public Ball ball=null;
    public Poin point =null;

Upvotes: 3

Related Questions