该程序将在Linux(Ubuntu 16.04)的命令行中运行。 董事会课程为我们部分编码。
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
}
}
董事会成员:
/*
* 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];
}
}
我不知道如何在LOA类的第一个代码块中初始化该板。我想制作董事会,例如。 5.所以我会插入命令行~$ java Loa 5
但我不知道应该以静态方式访问它意味着什么。
我在Java上使用Atom的原因是大学还不希望我们使用IDE。我不知道为什么。
The static method newBoard(int) from the type Board should be accessed in a static way
这是原子抛出的警告/错误。我很困惑,因为在我的一点编码经验中我还没有看到这个警告。
我可以使用更多代码来理解静态警告方法。