Originally Posted by
Kranti1992
My Problem 1: One of the methods we have to right is a "getTurn()" method, which needs to say who's turn it is (the whites or the blacks). To do this we need to return
either Piece.WHITE or Piece.BLACK (its related to the enum code provided below). Whites always starts. How do I do this? I know its a if else statement
but I'm pretty new to java so I'm not sure how it works. I need a toggle type if else statement so that players take turns.
How do you know whose turn it is? What do you mean by a "toggle type if else statement"? Again, I suggest you put together an SSCCE demonstrating just this problem.
Originally Posted by
Kranti1992
My Problem 2: I also need to write another method "startGame()" which generates the board via a 2d array with either WHITE, BLACK, or NONE spaces (as shown in the
enum code pasted).
Its a 4x6 board like this : (B = Black piece, W = White piece, N = empty space)
W W W W
W W W W
N N N N
N N N N
B B B B
B B B B
how do I make a 2d array that "generates" this board if called upon the method.. I know how to print out the array of these whites and blacks, but it just needs a void method that if called upon generates the board and starts the game. What do I write for it to be such a method?
Well, how is an array declared and initialized? Again, an SSCCE of just this problem would be easier to address than the code you posted, which doesn't really help with these problems.
Recommended reading:
The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Enum Types (The Java™ Tutorials > Learning the Java Language > Classes and Objects)