PrintGame
Class LabyrinthField

java.lang.Object
  extended byPrintGame.Field
      extended byPrintGame.LabyrinthField
All Implemented Interfaces:
java.lang.Cloneable

public class LabyrinthField
extends Field
implements java.lang.Cloneable

class representing a two dimensional labyrinth


Field Summary
protected  int cls
           
protected  java.lang.String name_
           
protected  int num_diamonds_
          the number of diamonds distributed in the field (set from outside of the class with the appropriate method-calls
protected  int num_wall_cells_
          the number of none way cells e.g.way cells (set from outside of the class with the appropriate method-calls
protected  int num_way_cells_
          the number of way cells distributed in the field (set from outside of the class with the appropriate method-calls
protected  int rws
           
protected  Direction start_direction_
           
protected  int start_point_col_
           
protected  int start_point_row_
           
 
Fields inherited from class PrintGame.Field
field_
 
Constructor Summary
LabyrinthField(int rows, int cols)
          Standard constructor
 
Method Summary
 java.lang.Object clone()
          This is used to make a copy of the whole object, but unlike what one would expect from a clone() method, this one does a deep copy!
 boolean containsDiamond(int row, int col)
           
 void convertToStartpoint(int row, int col)
           
 void convertToWall(int row, int col)
           
 void convertToWay(int row, int col)
           
 int getCellMark(int row, int col)
           
 java.lang.String getName()
           
 int getNumDiamonds()
           
 int getNumWallCells()
           
 int getNumWayCells()
           
 Direction getStartDirection()
           
 int getStartpointCol()
           
 int getStartpointRow()
           
 boolean isEmpty(int row, int col)
           
 boolean isStartDirection()
           
 boolean isStartpoint()
           
 boolean isStartpoint(int row, int col)
           
 boolean isWall(int row, int col)
           
 boolean isWay(int row, int col)
           
 void removeDiamond(int row, int col)
           
 void removeStartpoint(int row, int col)
           
 void setCellMark(int row, int col, int cell_mark)
          Sets one of the numbers {0,1,2,3} to the cell.
 void setDiamond(int row, int col)
           
 void setEmpty(int row, int col)
           
 void setName(java.lang.String name)
           
 void setStartDirection(Direction direction)
           
 java.lang.String toString()
          standard toString method for debugging
 boolean wereAllDiamondsFound()
          package-internal method that returns if all diamonds were found according to the internal counters
 
Methods inherited from class PrintGame.Field
getNumCols, getNumRows
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

num_diamonds_

protected int num_diamonds_
the number of diamonds distributed in the field (set from outside of the class with the appropriate method-calls


num_way_cells_

protected int num_way_cells_
the number of way cells distributed in the field (set from outside of the class with the appropriate method-calls


num_wall_cells_

protected int num_wall_cells_
the number of none way cells e.g.way cells (set from outside of the class with the appropriate method-calls


start_point_row_

protected int start_point_row_

start_point_col_

protected int start_point_col_

start_direction_

protected Direction start_direction_

name_

protected java.lang.String name_

rws

protected int rws

cls

protected int cls
Constructor Detail

LabyrinthField

public LabyrinthField(int rows,
                      int cols)
               throws java.lang.IllegalArgumentException
Standard constructor

Parameters:
rows - the number of rows of this labyrinth
cols - the number of columns of this labyrinth
Throws:
java.lang.IllegalArgumentException - thrown if either rows or cols is < 0
Method Detail

clone

public java.lang.Object clone()
This is used to make a copy of the whole object, but unlike what one would expect from a clone() method, this one does a deep copy! This function is intended to be called from loadLabyrinth(), where backups of the labyrinth are necessary.

See Also:
LevelHandler.loadLevel(int, boolean)

setCellMark

public void setCellMark(int row,
                        int col,
                        int cell_mark)
                 throws java.lang.IllegalArgumentException
Sets one of the numbers {0,1,2,3} to the cell.

Parameters:
row - Set the cellmark to this row
col - Set the cellmark to this column
cell_mark - is the number to be written
Throws:
java.lang.IllegalArgumentException

setDiamond

public void setDiamond(int row,
                       int col)
                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

setStartDirection

public void setStartDirection(Direction direction)

removeDiamond

public void removeDiamond(int row,
                          int col)
                   throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

removeStartpoint

public void removeStartpoint(int row,
                             int col)
                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

convertToWay

public void convertToWay(int row,
                         int col)
                  throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

convertToWall

public void convertToWall(int row,
                          int col)
                   throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

convertToStartpoint

public void convertToStartpoint(int row,
                                int col)
                         throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getNumDiamonds

public int getNumDiamonds()

getNumWayCells

public int getNumWayCells()

getNumWallCells

public int getNumWallCells()

isWay

public boolean isWay(int row,
                     int col)
              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

isWall

public boolean isWall(int row,
                      int col)
               throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

isStartpoint

public boolean isStartpoint(int row,
                            int col)
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

isStartpoint

public boolean isStartpoint()

getCellMark

public int getCellMark(int row,
                       int col)
                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getStartpointRow

public int getStartpointRow()
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getStartpointCol

public int getStartpointCol()
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getStartDirection

public Direction getStartDirection()

isStartDirection

public boolean isStartDirection()

containsDiamond

public boolean containsDiamond(int row,
                               int col)
                        throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

wereAllDiamondsFound

public boolean wereAllDiamondsFound()
package-internal method that returns if all diamonds were found according to the internal counters


setEmpty

public void setEmpty(int row,
                     int col)
              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

isEmpty

public boolean isEmpty(int row,
                       int col)
                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toString

public java.lang.String toString()
standard toString method for debugging

Overrides:
toString in class Field
Returns:
info about the labyrinth field in string-format