if (speedPreset == 2){
// ..
} else if(speedPreset == 1){
// ..
} else if(speedPreset == 0) {
// ..
}
private static final int STOP_PRESET = 0;
private static final int PLANETARY_SPEED_PRESET = 1;
private static final int CRUISE_SPEED_PRESET = 2;
enum SpeedPreset {
STOP(0), PLANETRAY(1), CRUISE(2);
}
class Inventory{
private List<Supply> supplies = new ArrayList<>();
void disposeCOntaminatedSupplies() {
for (Supply supply : supplies) {
if (supply.isContaminated()){
supplies.remove(supply); // 금지 !! 이러면 망함
}
}
}
}
// Iterator를 활용하면 괜찮음
void disposeCOntaminatedSupplies() {
Iterator<Supply> iter = supplies.iterator();
while (iter.hasNext()) {
if (iter.next().isContaminated()){
iterator.remove();
}
}
}