0

The program will run in the command line in Linux (Ubuntu 16.04). The Board class was partially coded for us.

public class Loa{
  public static void main(String[] args) {

    int boardSize = Integer.parseInt(args[0]);
    Board playBoard = new Board();


    playBoard.newBoard(boardSize);//atom gives a warning on this line. about static method
  }
}

Board class:

/*
 * This class implements the board. It stores an array that contains the content
 * of the board, and several functions that perform operations such as moving a
 * piece or counting the number of markers in a row, column, or diagonal.
 */
public class Board {

    // The size of the board
    private static int size;

    // The pieces
    public static final int INVALID = -1;
    public static final int EMPTY = 0;
    public static final int WHITE = 1;
    public static final int BLACK = 2;

    // The board
    private static int[][] board;
    // Convention: board[0][0] is the southwest square

    /*
     * Create and set up a new board
     */
    public static void newBoard(int newSize) {
        /*--------------------------------------------
         * FILL IN THE CODE FOR INITIALIZING THE BOARD
         *-------------------------------------------*/
         if (newSize > 16 || newSize < 4) {
            System.out.println("Error, invalid size.  Please enter a size from 4 - 16.");
        }else {
            size = newSize;
            board = new int[newSize][newSize];
        }

    }

I do not know how to initialize the board like in the first code block in LOA class. I want to make the board eg. 5. So I would put in the command line ~$ java Loa 5 But I do not know what it means that it should be accessed in a static way.

The reason I am using Atom for java is that the University doesn't want us to use an IDE yet. I don't know why.

The static method newBoard(int) from the type Board should be accessed in a static way

This is the warning/error that atom throws up. I am confused as I haven't seen this warning yet in my little bit of coding experience.

There is more code available but not necessary for me to understand the Static warning method.

Wihan Uys
  • 95
  • 2
  • 14

0 Answers0