Мне нужно изменить fuelType
и mode
независимо на каждой из отдельных станций, но я не могу понять, как это сделать, я могу распечатать массив, но не могу понять, как изменить его содержимое
station = new Pumps [10];
station[0] = new Pumps(" P101", "Idle", "Default", 0.0, 0.0, 0.0);
station[1] = new Pumps(" P102", "Idle", "Default", 0.0, 0.0, 0.0);
station[2] = new Pumps(" P103", "Idle", "Default", 0.0, 0.0, 0.0);
station[3] = new Pumps(" P104", "Idle", "Default", 0.0, 0.0, 0.0);
station[4] = new Pumps(" P105", "Idle", "Default", 0.0, 0.0, 0.0);
station[5] = new Pumps(" P201", "Idle", "Default", 0.0, 0.0, 0.0);
station[6] = new Pumps(" P202", "Idle", "Default", 0.0, 0.0, 0.0);
station[7] = new Pumps(" P203", "Idle", "Default", 0.0, 0.0, 0.0);
station[8] = new Pumps(" P204", "Idle", "Default", 0.0, 0.0, 0.0);
station[9] = new Pumps(" P205", "Idle", "Default", 0.0, 0.0, 0.0);
Пользователь должен найти станцию по ее ID, например. P101, затем измените каждое значение, которое говорит Idle и Default
Это мой класс объекта:
public class Pumps {
private String pumpID;
private String mode;
private String fuelType;
private double total;
private double pumpOutPut;
private double pumpInTake;
//Constructor
public Pumps ( String pumpID, String mode, String fuelType, double total ,
double pumpOutPut, double pumpInTake){
this.pumpID = pumpID;
this.mode = mode;
this.fuelType = fuelType;
this.total = total;
this.pumpOutPut = pumpOutPut;
this.pumpInTake = pumpInTake;
}
//*************Pump-ID*********************
public String getPumpID() {
return pumpID;
}
public void setPumpID(String pumpID) {
this.pumpID = pumpID;
}
//*************MODE*********************
public void setMode(String newMode) {
this.mode = newMode;
}
public String getMode() {
return mode;
}
//*************FUEL-TYPE*********************
public void setFuelType(String newFuelType) {
this.fuelType = newFuelType;
}
public String getFuelType() {
return fuelType;
}
//*************PUMP-IN-TAKE*********************
public void setPumpInTake(double pumpInTake) {
this.pumpInTake = pumpInTake;
}
//**************PUMP-OUT-PUT********************
public void setPumpOutPut(double pumpOutPut) {
this.pumpOutPut = pumpOutPut;
}
//*************TOTAL*********************
public void setTotal(double total) {
this.total = total;
}
}