帮顶,一个瓶子的粗糙实现!
class Bottle {
private final int capacity;
Bottle(int capacity) { this.capacity = capacity; }
private int size;
void fill() { size = capacity; }
void pour(Bottle bottle) {
bottle.size += size;
size = bottle.size > bottle.capacity ? bottle.size - bottle.capacity : 0;
bottle.size -= size;
}
}