Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners initialising a checkers board
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Louise
initialising a checkers board
0 Answer(s)      2 years and 3 months ago
Posted in : Java Beginners


Hi there

I am new to java and i am trying to place checkers pieces into a checker board which is set up as an array. What i have done so far is create an array and fill it with nothing. I have then created a copy and now want to place the appropriate pieces into the array

Here is my code

 public class Checkerboard  {
      // Constructors
      private Object checkerboard;;

// Creates a checkerboard where all the squares are empty. public Checkerboard() { Checker checkerboard[][] = new Checker[8][8]; for (int i=0; i < 8; i++) for (int j=0; j < 8; j++) checkerboard[i][j] = new Checker(null); }

public Checkerboard(Checkerboard old) { if (old == null) { System.out.println("Fatal error: copying null Checker"); System.exit(1); } this.checkerboard = old.checkerboard; } public void initialise() { Checker checkerboard[][] = new Checker[8][8]; for (int i=0; i < 1; i++) for (int j=0; j < 7; j=+2) checkerboard[i][j] = new Checker(true); for (int i=1; i < 2; i++) for (int j=1; j < checkerboard.length; j=+2) checkerboard[i][j] = new Checker(true); for (int i=2; i < 3; i++) for (int j=0; j < 7; j=+2) checkerboard[i][j] = new Checker(true); for (int i=5; i < 6; i++) for (int j=0; j < 7; j=+2) checkerboard[i][j] = new Checker(false); for (int i=6; i < 7; i++) for (int j=1; j < checkerboard.length; j=+2) checkerboard[i][j] = new Checker(false); for (int i=7; i < checkerboard.length; i++) for (int j=0; j < 7; j=+2) checkerboard[i][j] = new Checker(false); } }

My checker piece is in another class and is boolean type (red = true, black = false). I know I need to access the Checker piece, but I'm really not sure how to do this. And it seems really messy to have 6 for loops. Any advice would be very helpful.

Thanks


Advertisement
View Answers

Related Tutorials/Questions & Answers:
initialising a checkers board
initialising a checkers board  Hi there I am new to java and i am trying to place checkers pieces into a checker board which is set up as an array. What i have done so far is create an array and fill it with nothing. I have
initialising a checkers board
initialising a checkers board  Hi there I am new to java and i am trying to place checkers pieces into a checker board which is set up as an array. What i have done so far is create an array and fill it with nothing. I have
Advertisements
scoring board - Ajax
scoring board  Need code in Ajax to create a scoring board to display score on it.  Hi,You can use <meta http-equiv="refresh" content="600"> tag of HTML to automatically refresh the page
How to make an electronic advertising board, make an electronic advertising board, electronic advertising board
How to make an electronic advertising board       This is an electronic advertising board... according to your electronic advertising board size. Choose Color: Set
Java, MouseEvents, MouseClick, GameOfLife board - Java Beginners
Java, MouseEvents, MouseClick, GameOfLife board  Hi, I am working on Java programming and I have a project called Game of Life. I created a board... a dead cell). I tried to add cells to the board by mouseClick and it seems
How to show database values in Graph.(Like Cricket score board Graph)
How to show database values in Graph.(Like Cricket score board Graph)  Hi, Can Any one help out! How to show database values in Graph. i mean while....(Like Cricket score board Graph)   import java.sql.*; import
eSpell
eSpell       Eclipse Spell Checker Plug-in 2 Generic spell checker plug-in for the Eclipse 2.1 platform. Includes special purpose spell checkers for Java, JavaScript
If you came on board with us, what changes would you make in the system?
If you came on board with us, what changes would you make in the system?       This seemingly innocent question has many landmines hidden in it. You might be very close
Visit to Fatehpur Sikri
Fatepur Sikri. But the better option would be to board a bus from Idgah Bus Station..., it is recommended to board a bus before dark since transportation from Fathepur Sikri at night
Graphic interface java help
Graphic interface java help  A modified checkers program with class name Checkers using double buffering. Somehow the program must have two top squares and two bottom squares. There should be two checkers of different color
c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks
c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks
Javascript matrix error
) whenever it is called function valid(n){ //n is a number 0-9 if(board...; } } where board is a global 3x3 Array matrix var board = new Array(3); board[0]=new Array(3); board[1]=new Array(3
Constructor in Servlet.
Constructor in Servlet.  how to write a constructor in Java Servlet?   Servlet is like a POJO .You can create constructor in servlet. You can also use constructor for initialising purpose but it is not a useful approach
Grand Strategy
Grand Strategy       Grand Strategy is a free, web-based game inspired by the board game Risk. Read full Description
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
TOPCASED workshop
provides model editors, model checkers and model transformations, but is also
Tic Tac Toe extended - Java Beginners
; public class TicTacToe { private char board[][]; //Represents a board... col; String r = ""; String str = ""; char size = board[n][n]; char position = board[row][col]; boolean status; int moveCounter
help me
to join.The checkers will take random amounts of time to process each customer
ATLFlow
it as an planing and execution board. For more information: http
java program - Java Beginners
in this question This program represents the peg jumping puzzle. The board starts... for a move to be valid. The jumped peg is then removed from the board. The game is over.... ----------------------- Board Positions o A + + B C + + + D E F + + + + G H I J + + + + + K L M N O
Generating Random Numbers to Fill array. Java Beginner needing help!
*/ public class TwoDArrayExamples { private char[][] board; public...(System.in); char play = 0; while (play != 'q...()); } } private void initializeArray(){ board = new char [3][3
Netbeans program
. The constructor should initialize the empty board to all zeros. It should have a method...). If it is not a valid move the board does not change and it returns a Boolean value of false... that will display the current state of the board. The last method should
RECYCLING SYSTEM IN JAVA WITH BLUEJ
three parameters, initialising the two text fields and the deposit value field
Increase Web Traffic,How to Increase Web Traffic,Increase Website Traffic,Free Tips to Increase Website Traffic
engines are Web Directory and Discussion Board/Forums. Driving traffic to your... Traffic by Discussion Board/Forums Discussion Board and Forums are also a good way... Board to discuss about the technologies/articles on your website. In this way
java
java  I Want my jTextfield not to accept any keys from key board but display the calculation part in it ....can you plez help me..... private void... not to accept any keys from key board but display the calculation part
JQuery
to select option using key-board (means using key-down
Developer discussion forums
questions. A good discussion board software discussed all the programming
8 - Java Beginners
8  Unit board is PIC18F4520 Purpose of euiqpment is to make test heart beat; fast/slow/moderate heartbeat I need to activate the speaker when testing for heartbeat. Should be able to start buzzing when testing is done. Should
 

 

 

DMCA.com