I have the method Mappa() that creates the array settore (using the coordinates of the method Settore() of the class Settore) and the numeric Matrix Matrice. The class Settore has several subclasses (i'm using the subclass Sicuro to explain the code) that set the attribute SettoreNome from the enum Nome for an specific set of coordinates. I'm creating the method MappaCreator() that specifies the SettoreNome of each Settore(x,y) according to the value of the Matrice[x][y] and it seems that i'm not calling the method correctly because i get the error that the method is undefined for the subclass Sicuro.
package mappa;
public class Settore {
private Nome settoreNome;
private char letteraX;
private final int coordinataX;
private final int coordinataY;
private int giocatoriPresenti;
public int getGiocatoriPresenti() {
return giocatoriPresenti;
}
public void setGiocatoriPresenti(int giocatoriPresenti) {
this.giocatoriPresenti = giocatoriPresenti;
}
public char getLetteraX() {
return letteraX;
}
public void setLetteraX(char letteraX){
this.letteraX = letteraX;
}
public Settore (int coordinataX, int coordinataY){
this.coordinataX=coordinataX;
this.coordinataY=coordinataY;
}
public int getX(){
return coordinataX;
}
public int getY(){
return coordinataY;
}
public Nome getSettoreNome() {
return settoreNome;
}
public void setSettoreNome(Nome settoreNome) {
this.settoreNome = settoreNome;
}
public static void add(Settore[][] settore) {
// TODO Auto-generated method stub
}
}
package mappa.product;
import mappa.Settore;
public class Mappa {
private Name mappaName;
private final Settore [][] settore;
private int Matrice [][];
private static final int X=23;
private static final int Y=14;
public Mappa (){
settore = new Settore[X][Y];
for (int i=0; i < X; i++){
for (int j=0; j<Y; j++) {
settore[i][j] = new Settore (i,j);
}
}
Matrice = new int[23][14];
}
public int[][] getMatrice() {
return Matrice;
}
public void setMatrice(int matrice[][]) {
Matrice = matrice;
}
public Name getMappaName() {
return mappaName;
}
public void setMappaName(Name mappaName) {
this.mappaName = mappaName;
}
public Settore[][] getSettori(){
return settore;
}
public void addSettori(){
Settore.add(settore);
}
}
package mappa.creator;
import mappa.product.*;
import mappa.*;
public class MappaCreator {
protected Mappa mappa;
protected Settore settore;
protected int x;
protected int y;
public MappaCreator(){
Mappa mappa = new Mappa();
this.mappa=mappa;
int x; int y;
if (mappa.getMatrice()[x][y]==1){
Sicuro.Sicuro(x,y); //this is where i get the error
}
}
public void createMappa(){
Mappa mappa = new Mappa();
this.mappa=mappa;
}
public void createSettore(){
Settore settore = new Settore(x,y);
this.settore=settore;
}
}
package mappa;
public class Sicuro extends Settore {
public Sicuro(int coordinataX, int coordinataY) {
super(coordinataX, coordinataY);
setSettoreNome(Nome.SICURO);
}
}
package mappa;
public enum Nome {
SICURO, PERICOLOSO, SCIALUPPA, ALIENI, UMANI
}