Board Class -- This class is not part of JAVA, but has been created by the CS department in order to help
young programmers understand certain concepts. Since it is not a part of JAVA, in order to use it you must
either have the class files reference in Dr.Java's path, OR you must have a copy of the
Board.class and Coordinate.class files in the directory the rest of your files that
you are currently working on are located. A class file is essentially a .java file, such as
the ones you have created, but is compiled. Once you are finished your java files and compile them you
will also notice that your files have .class files. These are what Dr. Java runs. Therefore, if you
make a change to your java file, but forget to recompile it, then when you run it Dr. Java will be
using the old class file that you make have compiled previously. After you make a change you must click
'Compile' again so that Dr. Java makes a new class file which represents your current java
file code. If the Board/Coordinate classes are properly setup (see these instructions if not done yet),
then you can use the Board object much like you used the Scanner object. You would first declare and initialize
it like we did above:
Board aBoard;
aBoard = new Board(4, 5);
or, alternatively, a more short hand version is
Board aBoard = new Board(4, 5);
Notice that the parameters accepted when making a Board are different then those of the
Scanner class. The Board class either accepts one integer value, or two integer
values. Accepting one integer value creates a Board of height 1, but with a width of the specified integer.
When you give it two integers, it creates a board using the two different integers.
Now that the board is created, much like the Scanner object you can use a variety of methods on it,
such as removePeg(int row, int col). An example of using the remove peg would be:
aBoard.removePeg(3,2); // removes a peg from row 3, and column 2
For a list of methods that can be used with Board objects please see the Board Documentation. This documentation is located under the Resources Page.