class Bucket { constructor({ capacity, volume = 0 }) { this.capacity = capacity this.volume = volume } fill() { this.volume = this.capacity } empty() { this.volume = 0 } isEmpty() { return this.volume === 0 } isFull() { return this.volume == this.capacity } pour(bucket) { const availableVolume = bucket.capacity - bucket.volume if (availableVolume > this.volume) { bucket.volume += this.volume this.volume = 0 } else { this.volume -= availableVolume bucket.volume += availableVolume } } string() { return `${this.volume}vol/${this.capacity}cap` } } module.exports = Bucket;