Chessboard
Author |
Message |
Jessica359
|
Posted: Mon Apr 21, 2008 8:03 am Post subject: Chessboard |
|
|
Ok so here we have to output a chessboard using arrays and that if the user give box 1,3 for example it has to output the colour of the box (black or white)
how would I write my array?
thnxs |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tallguy
|
Posted: Mon Apr 21, 2008 9:53 am Post subject: RE:Chessboard |
|
|
r u doinfg a chess game 4 ur final? |
|
|
|
|
|
[Gandalf]
|
Posted: Mon Apr 21, 2008 12:38 pm Post subject: Re: Chessboard |
|
|
You could have an 8x8 two dimensional array where the value of each element represents the colour of the corresponding square. A simple way to set the colour in the checkerboard pattern is to use mod on the array index (ie. if the index is odd the colour is white, otherwise it's black). Once you've done that all you need is simple user input and conditional statements. |
|
|
|
|
|
Jessica359
|
Posted: Mon Apr 21, 2008 1:10 pm Post subject: RE:Chessboard |
|
|
awesome thanks |
|
|
|
|
|
|
|