(n: number)
| 18 | |
| 19 | // Public methods |
| 20 | public add(n: number): boolean{ |
| 21 | // If the operation would leave an < 0 value, we stop |
| 22 | if(this.current + n < 0) |
| 23 | return false; |
| 24 | |
| 25 | // If we add a positive value, we also add it to the accumulated |
| 26 | if(n > 0) |
| 27 | this.setAccumulated(this.accumulated + n); |
| 28 | |
| 29 | // We add to the current value |
| 30 | this.setCurrent(this.current + n); |
| 31 | |
| 32 | // We return true |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | public load(): void{ |
| 37 | this.setAccumulated(Saving.loadNumber(this.savingPrefix + "Accumulated")); |
no test coverage detected