import java.awt.*;
import java.awt.event.*;
import javax.swing.JApplet;

public class CarApplet 
{
 private Image carLeft = null;
 private Image carRight = null;
 private Image carUp = null;
 private Image carDown = null;
 private Image carImage = null;
 private int direction = -1;
 privte Point carLocation = new Point(25,25);  ?  /*Over here this line 
 private int speed = 10;                                  * gets highlighted and  
                                                             *says semicolon required.//
 public void setCar(Image carImage)
 {
     this.carImage = carImage;
    }

    public Image getCar()
    {
        return carImage;
    }

    private int getDirection()
    {
        return Direction;
    }

    private void setDirection(int direction)
    {
        this.direction = direction;
    }

    private Point getCarLocation()
    (
    return carLoation
    }

    private void setCarLocation(Point carLocation)
    {
        this.carLocation = carLocation;
    }

    public void paint(Graphics g)
    {
        Image car = getCar();
        if (car == null)
        throw new RuntimeException("Error");
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(car, getCarLocation().x, getCarLocation(0.y, this);
    }

    public void init()
    {
        carLeft = getImage(getCodeBase(),"icon/left.gif");
        carRight = getImage(getCodeBase(),"icon/right.gif");
        carUp = getImage(getCodeBase(),"icon/up.gif");
        carDown = getImage(getCodeBase(),"icon/down.gif");

        setCar(carRight);
        addKeyListner(new KeyAdapter(0
        {
            public void keyPressed(KeyEvent e)
            {
                int locationX = getCarLocation().x;
                int locationY = getCarLocation().Y;

                int key = e.getKeyCode();
                switch(key)
                {
                    case KeyEvent.VK_up:
                    if (getDirection() != key)
                    setCar(carUp);
                    locationY -= speed;
               break;
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carDown);
                    locationY += speed;
               break;
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carLeft);
                    locationX -= speed;
               break;     
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carRight);
                    locationX += speed;
               break;
               default:
               break;
            }
            setDirection(key);
            setCarLocation(new Point(locationX,locationY));
            repaint();
        }});
    }
}

start quote:

import java.awt.*;
import java.awt.event.*;
import javax.swing.JApplet;

public class CarApplet 
{
 private Image carLeft = null;
 private Image carRight = null;
 private Image carUp = null;
 private Image carDown = null;
 private Image carImage = null;
 private int direction = -1;
 privte Point carLocation = new Point(25,25);  ?  /*Over here this line 
 private int speed = 10;                                  * gets highlighted and  
                                                             *says semicolon required.//
 public void setCar(Image carImage)
 {
     this.carImage = carImage;
    }

    public Image getCar()
    {
        return carImage;
    }

    private int getDirection()
    {
        return Direction;
    }

    private void setDirection(int direction)
    {
        this.direction = direction;
    }

    private Point getCarLocation()
    (
    return carLoation
    }

    private void setCarLocation(Point carLocation)
    {
        this.carLocation = carLocation;
    }

    public void paint(Graphics g)
    {
        Image car = getCar();
        if (car == null)
        throw new RuntimeException("Error");
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(car, getCarLocation().x, getCarLocation(0.y, this);
    }

    public void init()
    {
        carLeft = getImage(getCodeBase(),"icon/left.gif");
        carRight = getImage(getCodeBase(),"icon/right.gif");
        carUp = getImage(getCodeBase(),"icon/up.gif");
        carDown = getImage(getCodeBase(),"icon/down.gif");

        setCar(carRight);
        addKeyListner(new KeyAdapter(0
        {
            public void keyPressed(KeyEvent e)
            {
                int locationX = getCarLocation().x;
                int locationY = getCarLocation().Y;

                int key = e.getKeyCode();
                switch(key)
                {
                    case KeyEvent.VK_up:
                    if (getDirection() != key)
                    setCar(carUp);
                    locationY -= speed;
               break;
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carDown);
                    locationY += speed;
               break;
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carLeft);
                    locationX -= speed;
               break;     
                    case KeyEvent.VK_DOWN:
                    if (getDirection() != key)
                    setCar(carRight);
                    locationX += speed;
               break;
               default:
               break;
            }
            setDirection(key);
            setCarLocation(new Point(locationX,locationY));
            repaint();
        }});
    }
}

end quote.

So wat exactly is your problem? Outline it and put your code into the brackets

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.