import java.util.Arrays;

/**
  Class Pocket demonstrates Arrays class and 
  NullPointerException because it does not 
  initialize the coin objects in change array.
  
  @author A. Ozgelen

 */ 
public class Pocket{
    public Pocket() {
	change = new Coin[10]; 
    }

    /** @param numCoins - represents the number of coins that my pocket contains */
    public Pocket(int numCoins) {
	change = new Coin[numCoins];	
	for(int i = 0; i < change.length; i++) { 
	    change[i] = new Coin();
	}
    }
    
    /** Returns the face value of the i'th coin in pocket
	@param i is the i'th coin in the pocket
	@return the face value of the i'th coin
    */
    public int getFaceOfCoin(int i) {
	if(change[i] != null)
	    return change[i].getFace();
	else 
	    return -1;
    }

    @Override
    public String toString() {
	return "In my pocket: " + Arrays.toString(change);
    }

    private Coin[] change; 
}
