0
how can i improve this code?
management: observation and reporting. https://code.sololearn.com/cP8PTRNqho3p/?ref=app
4 Answers
0
do you see the first bug?? i invite you to really participate in this thinking. it refreshes the memory and gives new ideas.
0
If you call the class constructor Tank with a liquid object of volume greater than the latter's capacity ( Reservoir ) as suite. go come admire source code.
int min=3;
int max=5;
int observerId=1;
Fluid fluid =new Essence("super",max);
Tank tank=new Tank(fluid, min);
Gauge observer1=new Gauge(tank, observerId);
tank.putFluidVolume(0);
tank.putFluidVolume(2);
0
I expose you our famous method that to let a Zero pass.
public void putFluidVolume(double volume){
volume=Math.abs(volume);
if(volume==0){
this.message="no fluid to put!";
}else{
double newVolume=fluid.getVolume()+volume;
if(newVolume>=this.capacity){
this.message="full tank!";
setOccupancy(this.capacity);
}else{
this.message="successfully added!";
setOccupancy(newVolume);
}
}
this.setChanged();
this.notifyObservers();
}
0
Observer is deprecated