checkerBoard2

This problem checks your ability to create 2D arrays of objects based on a provided class with a non-default constructor.

Complete the method checkerBoard, which returns a 2D array of Tile objects representing the board for checkers. Checkers is a game played on an 8x8 board where the top-left-most tile is white. Every other tile from there alternates between black and white. The colors also alternate top-to-bottom.

The Tile class is shown below.

public class Tile{
   private boolean isBlack = false;
   public Tile(boolean color){
      isBlack = color;
   }
   public boolean getColor(){ return isBlack; }
}

The line below shows an example of creating a Tile object that is white.

Tile t = new Tile(false);

Remember, do not implement classes that are mentioned to be a part of the problem. Having issues with the final board result? What color are the last element in your first row and the first element in your 2nd row? They should both be the same color!


Type your solution        
Skills Practiced:
3.A
3.C
3.E
4.A
4.B
Copyright © StudyCS 2024 All rights reserved.