All,

I wonder if anyone has an opinion on this. What's better, this:

// Diagonal checks
if (board[0][0] == turn) {
    if (board[1][1] == turn) {
        if (board[2][2] == turn) {
            System.out.println();
            System.out.println(turn + " IS THE WINNER!!!");
            writeBoard();
            return true;
        }
    }
}

Or this:

// Diagonal checks
if ((board[0][0] == turn) && (board[1][1] == turn) && (board[2][2] == turn)) {
    System.out.println();
    System.out.println(turn + " IS THE WINNER!!!");
    writeBoard();
    return true;
}

This is one of those cases where I'm never sure which way to go. Does anyone have a preference and a good reason for it?

Thanks,
Bill

I vote for the second version. The extra lines and indentation in version 1 create a lot of clutter and will push the following code off the screen - just imagine it inside a loop inside a method definition...

I like the second version better too. I'm pretty much sticking with that, but will use whatever makes for the easiest reading.

Thanks,
-Bill

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.