All pastes #344606 Raw Edit

Mine

public text v1 · immutable
#344606 ·published 2007-02-07 21:35 UTC
rendered paste body

/**
 * Write a description of class FutoshikiPuzzle here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class FutoshikiPuzzle
{
    // instance variables - replace the example below with your own
    public static final int GRIDSIZE = 5;
    private int[][]  grid;
    private String[][] rowConstraints;
    private String[][] columnConstraints;

    /**
     * Constructor for objects of class FutoshikiPuzzle
     */
    public FutoshikiPuzzle()
    {
        // initialise instance variables
        grid = new int[5][5];
        rowConstraints = new String[5][4];
        columnConstraints = new String[4][5];
     
    }

    /**
     * An example of a method - replace this comment with your own
     * 
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y 
     */
    public void setSquare(int rowPosition, int columnPosition, int numberBeingEntered)
    {
        // put your code here
        grid[rowPosition][columnPosition] = numberBeingEntered;
    }
    
    public int getNum(int rowPosition, int columnPosition)
    {
        return grid[rowPosition][columnPosition];
    }
    
    public void setRowConstraint()
    {
        rowConstraints[0][2] = " < ";
        rowConstraints[2][0] = " > ";
        rowConstraints[2][2] = " > ";
        rowConstraints[4][0] = " > ";
    }
    
    public void setColumnConstraint()
    {
        columnConstraints[1][0] = " v ";
        columnConstraints[1][2] = " ^ ";
        columnConstraints[2][2] = " v ";
        columnConstraints[3][2] = " v ";
        columnConstraints[0][3] = " v ";
        columnConstraints[2][3] = " v ";

    }
    
    public void fillPuzzle()
    {
         setSquare(0, 0, 1);
         setSquare(0, 2, 4);
         setSquare(2, 1, 4);
         setSquare(2, 2, 3);
         setSquare(4, 0, 3);
         setRowConstraint();
         setColumnConstraint();
    }
    
    public void printPuzzle()
    {
        int y = 0;
        for (int x = 0; x < GRIDSIZE; x++)
        {
            String container = "";
            String container1 = "";
                while (y < GRIDSIZE) 
                {
                    container = ("| " + grid[x][y] + " |");
                    System.out.println(" " + "---");
                    System.out.println(container);
                    System.out.println(" " + "___");
                    System.out.println("   ");
                    y++;
                }
            

        }
    }
      
                          
}