Salve ragazzi, non ho capito bene cosa fa questo pezzo di codice:
In particolare non ho capito che cosa fanno queste righe di cosice:Codice PHP:public Stazioni(){
//caricamento informazioni dal file
try{
BufferedReader f = new BufferedReader(new FileReader("valori.txt"));
String s;
while((s = f.readLine()) != null){
STAZIONI.add(new stazione(stazione.tipo_stazione.valueOf(s),Float.parseFloat(f.readLine())));
}
f.close();
}catch(FileNotFoundException fnf){
System.out.println("File non trovato");
System.exit(1);
}catch(IOException ioe){
System.out.println("Errore di IO");
System.exit(1);
}
}
lass stazione{
enum tipo_stazione { MARITTIMA, TERRESTRE, AEREA };
tipo_stazione tipo;
float valore_sensore;//il valore viene simulato con un oggetto random
//in base al tipo di stazione il valore del sensore va interpretato come
//velocità moto ondoso, grado sismico in atto, pressione atmosferica
public stazione(tipo_stazione ts, float valore){
this.tipo = ts;
this.valore_sensore = valore;
}
}
enum tipo_stazione { MARITTIMA, TERRESTRE, AEREA };
tipo_stazione tipo;
ed
STAZIONI.add(newstazione(stazione.tipo_stazione.va lueOf(s),Float.parseFloat(f.readLine())));
in particolare stazione.tipo_stazione.valueOf(s) cosa fa questo?

Rispondi quotando