0
The method needs to return the lines that has given number of adjoining armchairs of a sector, I tried as follows(I could not do functional):
public String buscaContigua(int s, int c){
String msg = "";
String letras ="ABCDEFGHIJKL";
int c2=c;
for(int i=0; i<sala.length; i++){
c=c2;
for(int j=0; j<sala[i].length; j++){
if(sala[i][j].getSetor()==s){
if(sala[i][j].estaOcupada()==false)c--;
if(sala[i][j].estaOcupada()) c=c2;
}
if(c==0)msg = ""+letras.charAt(i) + ", ";
}
}
msg = "Existem poltronas contiguas nas filas: " + msg;
if(msg.length()<39) msg = "Não existem contiguas com esse número nesse setor.";
return msg;
This method initiates the theatre[12][20]
public void inicializa(){
String letras ="ABCDEFGHIJKL";
int setor;
for(int i=0; i<sala.length; i++){
if(i<=2) setor = 0;
else setor = 3;
for(int j=0; j<sala[i].length; j++){
if(i>2 && i<8){
if(j<=9) setor = 1;
else setor = 2;
}
sala[i][j] = new Poltrona(""+letras.charAt(i)+j,setor);
}
}
}
sala
is a variable of the typePoltrona[][]
?– Victor Stafusa
Yes, the dimensions are [12][20]
– Mateus José da Silva Monteiro
You can give an example of input and output values to make it clearer what you are trying to achieve ?
– Isac