#Is this well documented
32 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @thorn oxide! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Format your code please
/**
* Throws a QwirkleException if 2 tiles
* are equal in a tile's array or if one of
* them has different color AND shape than the
* rest (they can have different color or different
* shape but never both different)
* @param tiles the array of tiles to check
*/
public void checkrules(Tile[] tiles){
if (tiles.length > 6){
throw new QwirkleException();
} // Throws a QwirkleException if the length of the array we are trying to play with is bigger than 6.
for (int i = 0; i < tiles.length; i++){
if (tiles[0].shape() != tiles[i].shape() && tiles[0].color() != tiles[i].color()){
throw new QwirkleException();
} // Throws a QwirkleException if one of the tiles has different color AND different shape than the rest of tiles in the array.
for (int k = i + 1; k < tiles.length; k++){
if (tiles[i] == tiles[k]){
throw new QwirkleException();
} //Throws a QwirkleException if one of the tiles is equal to another tile in the array
}
}
}
/**
* Method that puts the first tiles to play with in the grid
* @param d direction in which the line of tiles will be added
* @param line array containing the tiles used to start the game with
*/
public void firstAdd(Direction d, Tile... line){
if (!Empty){ // If the game has already started throw an exception
throw new IllegalArgumentException("This isn't the first add " + Empty);
}
checkrules(line);
int startRow = 45; // Row in which to place the first tile
int startCol = 45; // Column in which to place the first tile
this.tiles[startRow][startCol] = line[0]; // Placement of the first tile
for (int i = 1; i < line.length; i++){
this.tiles[startRow + d.getDeltaRow()][startCol + d.getDeltaCol()] = line[i]; // Places the tile in desired direction
startRow = startRow + d.getDeltaRow(); // Updates the row after placing the tile
startCol = startCol + d.getDeltaCol(); // Updates the column after placing the tile
}
}
was just doing that :p @warm spruce
ill try again
Only thing is why don't you declare your method to throw the QuirkleException?
it does throw it no
throw new QwirkleException();
Like this!
Precisely
Yes
It's good that you describe the big picture and not just re-writing the code in words
tyty, will close the thread now, amazing help !
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.