import java.util.Arrays;

public class Board
{
  private int wide, high;
  private int theBoard[][]; //first subscript vertical displacement, second horizontal

  public Board(int wide, int high)
  {
    this.wide = wide;
    this.high = high;
    this.theBoard = new int[high][wide];
    for(int j = 0; j < wide; j++)
    {
      for(int i = 0; i < high; i++)
      {
        this.theBoard[i][j] = -1;
      }
    }
  }

  public Board(Board b)
  {
    this.wide = b.getWide();
    this.high = b.getHigh();
    this.theBoard = new int[high][wide];
    for(int j = 0; j < this.wide; j++)
    {
      for(int i = 0; i < high; i++)
      {
        this.theBoard[i][j] = b.getValue(i, j);
      }
    }
  }

  public int getWide()
  {
    return this.wide;
  }
 
  public int getHigh()
  {
    return this.high;
  }

  public int getValue(int down, int across)
  {
    return this.theBoard[down][across];
  }

  public void setValue(int down, int across, int what)
  {
    this.theBoard[down][across] = what;
  }

  public Move[] legalMoves(int x, int y)
  {
    Mpve retval[] = new Move[8];
    int nextMove = 0;
    for(int dx = -2; dx <= 2; dx++)
    {
      for(int dy = -2; dy <= 2; dy+)
      {
        if(dx != 0 && dy != 0)
        {
          newX = x + dx;
          newY = y + dy;
          if(newX >= 0 && newX < this.high && newY >= 0 && newY < this.wide && this.getValue(newY, newX) == -1)
          {
            retval[nextMove] = new Move(newY, newX);
          }
          else
          {
            retval[nextMove] = null;
          }
        }
      }
    } 
    return retval;
  }


  public String toString()
  {
    String retval = "";
    for(int i = 0; i < this.high; i++)
    {
      retval += Arrays.toString(this.theBoard[i]) + "\n";
    }   
    return retval;
  }

  public static void main(String args[])
  {
    Board b = new Board(4, 5);
    System.out.println(b);
    b.setValue(3, 2, 7);
    Board b2 = new Board(b);
    System.out.println(b2);
  }
}
  
    

