Boas, alguem me poderia informarcomo faço para converter estas linha de código usando ARRAY []
ex:
Obrigado pela atenção
ex:
Código:
String[] array = new string [10]
[COLOR=YellowGreen]//////////////////////////[/COLOR]
Linha de código
while(m < 24){
if(road == n){
road = 0;
traficlight = traficlight == '-' ? '|' : '-';
}
road++;
char[] vetchistory = new char[history.length()];
vetchistory = history.toCharArray();
for(int i = history.length()-2; i >= 0;i--){
if(traficlight == '-' || (traficlight == '|' && vetchistory[i+1] == '.')){
vetchistory[i+1] = vetchistory[i];
vetchistory[i] = '.';
}
}
System.out.println(car + ":" + m + ": " + history.toString() + traficlight);
if(car == 0 && vetchistory[0] == '.'){
vetchistory[0] = (char)alfacar;
history = String.copyValueOf(vetchistory);
if(alfacar == 90) alfacar = 65;
else alfacar++;
}else if(car == 0){
history = String.copyValueOf(vetchistory);
history = (char)alfacar + history.toString();
if(alfacar == 90) alfacar = 65;
else alfacar++;
}else{
history = String.copyValueOf(vetchistory);
history = "." + history.toString();
}
if(car == 0 || car == -1){
car = (int) Math.floor(Math.random()*d) + 1;
}
car--;
m++;
}
[COLOR=YellowGreen]//////////////////[/COLOR]
Última edição pelo moderador: