/**************
 * The basics of a Cup for the WaterJug Problem
 * This class is used by CupNode
 * Mark Goadrich 
 **************/
public class Cup {

    // Data Members to track the size and contents of the cup
    private int size = 0;
    private int contents = 0;

    // Constructor to initialize this cup
    public Cup(int size, int contents) {
        this.size = size;
        this.contents = contents;
    }

    // Accessor Methods to get the Size and Contents
    public int getSize() {
        return size;
    }

    public int getContents() {
        return contents;
    }

    // Returns a copy of the current Cup
    public Cup clone() {
        return new Cup(size, contents);
    }

    // Fill the Cup to the max with size
    public void fill() {
        contents = size;
    }

    // Empty the Cup of all contents
    public void empty() {
        contents = 0;
    }

    // pour from Cup c into this Cup
    public void pourFrom(Cup c) {
        if (c.contents + contents < size) {
            contents += c.contents;
            c.contents = 0;
        } else {
            c.contents -= size - contents;
            contents = size;
        }
    }
}
