import java.applet.*;
import java.awt.*;

public class RobotWorld
{
    private int world [] [] = new int [10] [10];
    private Color background;
    private Color outline;
    private Color wall;
    private Color dot;

    public RobotWorld ()
    { //Default constructor
	//colours are set
	background = Color.yellow;
	outline = Color.orange;
	wall = Color.black;
	dot = Color.red;
	//walls array is set to have no walls
	for (int i = 0 ; i < 10 ; i++)
	{
	    for (int j = 0 ; j < 10 ; j++)
	    {
		world [i] [j] = 0;
	    }
	}
    } //MyWorld constructor


    public Color getBackground ()
    { //returns the colour that the Robot can walk on
	return background;
    } //getBackground


    public Color getOutline ()
    { //returns the outline colour.
	return outline;
    } //getOutline


    public Color getWall ()
    { //returns the colour of the Wall
	return wall;
    } //getWall


    public void placeDot (int i, int j)
    { //places a red dot where instructed
	world [i] [j] = 2;
    }


    public void placeWall (int i, int j)
    { //places a wall where instructed
	world [i] [j] = 1;
    } //placeWall


    public boolean isOK (int xpos, int ypos)
    { //checks to make sure the robot can move in a given x,y co-ordinate
	if (((xpos - 100) / 30 < 0) || ((xpos - 100) / 30 > 9))
	    return false;
	if (((ypos - 100) / 30 < 0) || ((ypos - 100) / 30 > 9))
	    return false;
	if (world [(xpos - 100) / 30] [(ypos - 100) / 30] == 1)
	    return false;
	return true;
    } //isOK


    public void drawWorld (Graphics g)
    { //draw the grid in the colours stored in the instance variables.
	g.setColor (background);
	g.fillRect (100, 100, 300, 300);
	g.setColor (outline);

	for (int i = 0 ; i < 10 ; i++)
	{
	    for (int j = 0 ; j < 10 ; j++)
	    {
		if (world [i] [j] == 1)
		{ //fill the walls in if there is one.
		    g.setColor (wall);
		    g.fillRect (100 + (i * 30), 100 + (j * 30), 30, 30);
		    g.setColor (outline);

		}
		else if (world [i] [j] == 2)
		{
		    g.setColor (dot);
		    g.fillOval (107 + (i * 30), 107 + (j * 30), 15, 15);
		    g.setColor (outline);


		}
		g.drawRect (100 + (i * 30), 100 + (j * 30), 30, 30);
	    }
	}
    } //drawWorld
} //MyWorld class

