//notice Coke is an immutable class
class Coke {
    private String expDate;
    private String name;
    public Coke(String expDate) {
	this.expDate = expDate;
    }
    public String getExpDate() {
	return expDate;
    }
}

//this is review for arrays of objects and partially filled arrays
class VendMach {
    private Coke[] cokes;

  //not static--we'd like different coke machines to be able to have different capacities
    private final int CAPACITY; 
    private int currentCokeCount;
    public VendMach(int capacity) {
	CAPACITY = capacity;
	currentCokeCount=0;
	//next line *instantiates* the array object
	cokes = new Coke[CAPACITY];
    }
    public int getNumCokes() { return currentCokeCount; }
    public int getCapacity() { return CAPACITY; }
    public void loadCokes(String expDate) {
	//recall, we load at any time, and only load the empty slots
	for(int i=currentCokeCount; i<CAPACITY; ++i) {
	    cokes[i] = new Coke(expDate); //create a coke object, point ith array element to it
	}
	currentCokeCount = CAPACITY;
    }
    public Coke getCoke() {
	Coke returnValue;
	if(currentCokeCount==0) {
	    returnValue = null; //the Coke reference variable returnValue does not point to any object
        }
	else {
	    returnValue = cokes[currentCokeCount-1];
	    cokes[currentCokeCount-1] = null; //machine no longer has the coke
	    currentCokeCount--; //update coke count
	}
	return returnValue;
    }

}

//small tester for VendMach -- see tester file (useful for review)
