#Is this well documented

32 messages · Page 1 of 1 (latest)

thorn oxide
#

s

stoic brambleBOT
#

This post has been reserved for your question.

Hey @thorn oxide! Please use /close or the Close Post button 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.

warm spruce
#

Format your code please

thorn oxide
#
/**
     * 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

warm spruce
#

You can also add "java" after the three backticks for syntax highlighting

#

But yeah

thorn oxide
#

ill try again

warm spruce
#

Only thing is why don't you declare your method to throw the QuirkleException?

thorn oxide
#

it does throw it no

warm spruce
#

CheckRules function doesn't declare that it does

#

In the function's definition

thorn oxide
#

throw new QwirkleException();

warm spruce
#

No

#

After the parameter list, write "throws QuirkleException"

thorn oxide
#

below

#

or just next to parameter list

#

after the message

#

oh u mean like this

warm spruce
#

No

#

In the method definition

#

Look at, for example, Files.delete

thorn oxide
#

Like this!

warm spruce
#

Precisely

thorn oxide
#

alright and now

#

is it good documentation

warm spruce
#

Yes

#

It's good that you describe the big picture and not just re-writing the code in words

thorn oxide
#

tyty, will close the thread now, amazing help !

stoic brambleBOT