Java Reference
In-Depth Information
91.
return ( new ConfigurationModel(board));
92.
}
93.
94.
public int getNoOfCols(){
95.
return (noOfCols);
96.
}
97.
98.
public int getNoOfRows(){
99.
return (noOfRows);
100.
}
101.
}
The class MoveModel provides the abstract description of a move. It specifies the
number of the block to be moved and its direction. The direction is one of the
constants defined in class Constants .
File: its/BlockPuzzle/MoveModel.java
package its.BlockPuzzle;
1.
2.
3.
4.
public class MoveModel {
5.
6.
private int direction;
7.
private int blockNumber;
8.
9.
public MoveModel( int dir, int bn) {
10.
direction = dir;
11.
blockNumber = bn;
12.
}
13.
14.
public int getBlockNumber(){
15.
return (blockNumber);
16.
}
17.
18.
public int getDirection(){
return (direction);
19.
}
20.
}
21.
Instances of class ConfigurationModel represent a snapshot of the board. This
can be used to protocol the course of a game, or to store the current state of the
game. Method equals checks whether two configurations are identical. This can
be used for test purposes. The class provides a method toString which returns
the configuration in a format that can also be printed on the console.
Search WWH ::




Custom Search