I am developing a work for a college assigment. I have files, Validador.java, Peca.java, Tabuleiro.java
Validador.java:
public class Validador {
public static void main(String[] args) {
if(args.length == 0) { // sem argumentos
Tabuleiro tab = new Tabuleiro("DD--");
Peca peca = tab.peca(0,0);
}else if (args[0].equals("filtro")) { // argumento filtro
}
}
}
Peca.java :
public abstract class Peca {
Tabuleiro tab;
int linha;
int coluna;
public boolean isNada; //dps corrigir
Peca(Tabuleiro tab, int linha, int coluna) {
this.tab = tab;
this.linha = linha;
this.coluna = coluna;
}
boolean vazia() {
if(isNada == true) {
return true;
}else {
return false;
}
}
Tabuleiro.java
public class Tabuleiro extends Peca {
String repr;
char tabuleiro_array[][];
int tamanho_tabuleiro;
Tabuleiro(String repr) {
super();
this.repr = repr;
}
Peca peca (int linha, int coluna) {
if(this.tabuleiro_array[linha][coluna] == 'D') {
// return Rainha(tab,linha,coluna);
}else {
//return Nada(tab,linha,coluna);
}
return null;
}
}
And i am getting this error: The constructor Peca() is undefined
at Tabuleiro.<init>
at Validador . main
I know that I could put Tabuleiro(String repr, Tabuleiro tab, int linha, int coluna) { super(tab, linha, coluna) However my professor told us that Tabuleiro could only receive a string... Tabuleiro(String repr) Ideias?
You shouldn't have a Peca constructor in Tabuleiro. Instead, just pass the member data through super(data1,data2):
Tabuleiro(String repr) {
super(); // pass information here super(data1,data2), this is used to initialize the parent class
this.repr = repr;
}