package own.crazyit06.chapter6;
/**
 * Description:
 * <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
 * <br/>This program is protected by copyright laws.
 * <br/>Program Name:
 * <br/>Date:
 * @author  Yeeku.H.Lee kongyeeku@163.com
 * @version  1.0
 */
public class BetterPrinter implements Output
{
	private String[] printData = new String[MAX_CACHE_LINE * 2];
	//ÓÃÒÔ¼ÇÂ¼µ±Ç°Ðè´òÓ¡µÄ×÷ÒµÊý
	private int dataNum = 0;
	public void out()
	{
		//Ö»Òª»¹ÓÐ×÷Òµ£¬¼ÌÐø´òÓ¡
		while(dataNum > 0)
		{
			System.out.println("¸ßËÙ´òÓ¡»úÕýÔÚ´òÓ¡£º" + printData[0]);
			//°Ñ×÷Òµ¶ÓÁÐÕûÌåÇ°ÒÆÒ»Î»£¬²¢½«Ê£ÏÂµÄ×÷ÒµÊý¼õ1
			System.arraycopy(printData , 1, printData, 0, --dataNum);
		}
	}
	public void getData(String msg)
	{
		if (dataNum >= MAX_CACHE_LINE * 2)
		{
			System.out.println("Êä³ö¶ÓÁÐÒÑÂú£¬Ìí¼ÓÊ§°Ü");
		}
		else
		{
			//°Ñ´òÓ¡Êý¾ÝÌí¼Óµ½¶ÓÁÐÀï£¬ÒÑ±£´æÊý¾ÝµÄÊýÁ¿¼Ó1¡£
			printData[dataNum++] = msg;
		}
	}
}
