0

how can i improve this code?

management: observation and reporting. https://code.sololearn.com/cP8PTRNqho3p/?ref=app

17th Feb 2022, 6:41 PM
Mahatma Tefnakht
Mahatma Tefnakht - avatar
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.
17th Feb 2022, 6:54 PM
Mahatma Tefnakht
Mahatma Tefnakht - avatar
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);
17th Feb 2022, 7:09 PM
Mahatma Tefnakht
Mahatma Tefnakht - avatar
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(); }
17th Feb 2022, 7:14 PM
Mahatma Tefnakht
Mahatma Tefnakht - avatar
0
Observer is deprecated
19th Feb 2022, 3:52 AM
zemiak