从字面上看,我的程序正在运行,即将上交,然后为了安全起见再次编译它,这个错误?
我迫切需要一些快速帮助,因为我完全不知道为什么我的代码突然决定不再工作了:(((((((((((((((()))
TrominoSolver.java:175: error: constructor tromino in class tromino cannot be applied to given types;
tromino thisguy = new tromino(size, x, y);
^
required: no arguments
found: int,int,int
reason: actual and formal argument lists differ in length
为什么我会突然得到这个?
这是我的代码
import java.util.*;
public class TrominoSolver {
//create a drawing panel of width=400px and height=400px
private int[][] board;
private int currentNum;
// 0<=x<size, 0<=y<size
// create an empty tromino object of dimension size x size.
public void tromino(int size, int x, int y) {
int actualsize = 1;
while (actualsize < size) actualsize*=2; //actualsize = actualsize * 2
//Board is power of 2
board = new int[actualsize][actualsize];
currentNum = 1;
// Initialize with empty squares.
for (int i=0; i<actualsize; i++) {
for (int j=0; j<actualsize; j++) {
board[i][j] = 0;
}
}
// Hole in board
board[x][y] = -1;
}
// call for recursive method.
public void tile() {
tileRec(board.length, 0, 0);
}
private void tileRec(int size, int topx, int topy) {
// fill in your one tromino...
if (size == 2) {
// Fill in the one tromino. The hole is identified by a
// -num, don't fill in that one square.
for (int i=0; i<size; i++)
for (int j=0; j<size; j++)
if (board[topx+i][topy+j] == 0)
board[topx+i][topy+j] = currentNum;
// Advance to the next tromino.
currentNum++;
}
// Recursive case...
else {
// Find coordinates of hole
int yesx=topx, yesy=topy;
for (int x=topx; x<topx+size; x++)
for (int y=topy; y<topy+size; y++)
if (board[x][y] != 0) {
yesx = x;
yesy = y;
}
// Hole in upper left quadrant.
if (yesx < topx + size/2 && yesy < topy + size/2) {
// Recursively tile upper left quadrant.
tileRec(size/2, topx, topy);
// Fill in middle tromino
board[topx+size/2][topy+size/2-1] = currentNum;
board[topx+size/2][topy+size/2] = currentNum;
board[topx+size/2-1][topy+size/2] = currentNum;
// Advance to the next tromino
currentNum++;
// make other recursive calls.
tileRec(size/2, topx, topy+size/2);
tileRec(size/2, topx+size/2, topy);
tileRec(size/2, topx+size/2, topy+size/2);
}
// Hole in upper right quadrant
else if (yesx < topx + size/2 && yesy >= topy + size/2) {
// Recursively tile upper right quadrant.
tileRec(size/2, topx, topy+size/2);
// Fill in middle tromino
board[topx+size/2][topy+size/2-1] = currentNum;
board[topx+size/2][topy+size/2] = currentNum;
board[topx+size/2-1][topy+size/2-1] = currentNum;
// Go to the next tromino
currentNum++;
// make other recursive calls.
tileRec(size/2, topx, topy);
tileRec(size/2, topx+size/2, topy);
tileRec(size/2, topx+size/2, topy+size/2);
}
// Hole in bottom left quadrant
else if (yesx >= topx + size/2 && yesy < topy + size/2) {
// Recursively tile bottom left quadrant.
tileRec(size/2, topx+size/2, topy);
// Fill in middle tromino
board[topx+size/2-1][topy+size/2] = currentNum;
board[topx+size/2][topy+size/2] = currentNum;
board[topx+size/2-1][topy+size/2-1] = currentNum;
// Go to the next tromino
currentNum++;
// make other recursive calls.
tileRec(size/2, topx, topy);
tileRec(size/2, topx, topy+size/2);
tileRec(size/2, topx+size/2, topy+size/2);
}
else {
// Recursively tile bottom right quadrant.
tileRec(size/2, topx+size/2, topy+size/2);
// Fill in middle tromino
board[topx+size/2-1][topy+size/2] = currentNum;
board[topx+size/2][topy+size/2-1] = currentNum;
board[topx+size/2-1][topy+size/2-1] = currentNum;
// Go to the next tromino
currentNum++;
// Now we can make our three other recursive calls.
tileRec(size/2, topx+size/2, topy);
tileRec(size/2, topx, topy+size/2);
tileRec(size/2, topx, topy);
}
}
}
// Print out latest object
public void print() {
for (int i=0; i<board.length; i++) {
for (int j=0; j<board[i].length; j++)
System.out.print(board[i][j] + "\t");
System.out.println();
}
}
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
// user input...
int size = stdin.nextInt();
int x = stdin.nextInt();
int y = stdin.nextInt();
tromino thisguy = new tromino();
thisguy.tile();
// Print out the tromino board.
thisguy.print();
}
}