Java Reference
In-Depth Information
File: its/BlockPuzzle/ConfigurationModel.java
1. package its.BlockPuzzle;
2.
3.
4. public class ConfigurationModel {
5.
6. private int [][] board;
7. int noOfRows, noOfCols;
8.
9.
public ConfigurationModel( int [][] b) {
10.
noOfRows = b.length;
11.
noOfCols = b[0].length;
12.
board = new int [noOfRows][noOfCols];
13.
for ( int r=0;r < noOfRows ; r++ ) {
14.
for ( int c=0;c < noOfCols ; c++ ) {
15.
board[r][c] = b[r][c];
16.
}// for
17.
}// for
18.
}
19.
20. public int getBlockNo( int r, int c){
21. return (board[r][c]);
22. }
23.
24.
public String toString(){
25.
String confAsString = "";
26.
for ( int r=0; r < noOfRows; r++){
27.
for ( int c=0; c < noOfCols; c++){
28.
if (board[r][c] < 10)
29.
{
30.
confAsString += " "+board[r][c];
31.
}
32.
else
33.
{
34.
confAsString += " "+board[r][c];
35.
}// ifelse
36.
}// for c
37.
confAsString += " \ n";
38.
}//for r
39.
confAsString += " \ n";
40.
return (confAsString);
41.
}
42.
43.
public boolean equals(ConfigurationModel conf){
44.
boolean result = true ;
Search WWH ::




Custom Search