/**
 * A missive recorder in an instant messaging system.
 * In this version, there is a limit on the total number
 * of Chirp objects that can be recorded and all output is
 * sent to the console.
 *
 * @author  Prof. David Bernstein
 * @version 2.0
 */
public class ChirpRecorder
{
    private int            currentNumber;
    private Chirp[]        chirps;

    /**
     * Explicit Value Constructor
     *
     * @param size   The maximum number of Chirp objects to be recorded
     */
    public ChirpRecorder(int size)
    {
	chirps        = new Chirp[size];
	currentNumber = 0;
    }

    /**
     * Add a Chirp to this ChirpRecorder (if it is not
     * already full)
     *
     * @param msg   The Chirp to record
     */
    public void addChirp(Chirp msg)
    {
	if (currentNumber < chirps.length) {

	    chirps[currentNumber] = msg;
	    currentNumber++;
	}
    }

    /**
     * Show (on System.out) a previously recorded Chirp
     *
     * @param number   The number of the Chirp to show
     */
    public void showChirp(int number)
    {
	String     text;

	if (number < currentNumber) 
        {
	    text = chirps[number].getText();
	    System.out.println(text);
	} 
        else
        {
	    System.out.println("No such chirp!");
	}
    }
}
