Note: this is only a selected part of the SimpleMug class.
/** * A mug with a maximum capacity, a current amount of liquid, and a kind of * liquid. */ public class SimpleMug { // Data Members (fields) private int maxCapacity; // the maximum capacity of the mug private int currAmount; // the current amount of liquid in the mug private String liquidKind; // the kind of liquid in the mug /** * Constructs a mug with the given maximum capacity to be filled with a * given kind of liquid. The mug starts out empty. * @param mugCapacity the maximum capacity of the mug * @param kindLiquid the kind of liquid the mug will hold */ public SimpleMug(int mugCapacity, String kindLiquid) { maxCapacity = mugCapacity; currAmount = 0; liquidKind = kindLiquid; } /** * Fills the mug with the given amount of liquid. * @param amount the amount of liquid to add to the mug */ public void fill(int amount) { int newAmount = currAmount + amount; currAmount = newAmount; } ... }