package own.crazyit06.chapter7;

/**
 * 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 TeachableProgrammer extends Programmer
{
	public TeachableProgrammer(){}
	public TeachableProgrammer(String name)
	{
		super(name);
	}
	//½ÌÑ§¹¤×÷ÒÀÈ»ÓÉTeachableProgrammerÀà¶¨Òå
	private void teach()
	{
		System.out.println(getName() + "½ÌÊ¦ÔÚ½²Ì¨ÉÏ½²½â...");
	}
	private class Closure implements Teachable
	{
		/*
		 ·Ç¾²Ì¬ÄÚ²¿Àà»Øµ÷Íâ²¿ÀàÊµÏÖwork·½·¨£¬·Ç¾²Ì¬ÄÚ²¿ÀàÒýÓÃµÄ×÷ÓÃ½ö½öÊÇ
		 Ïò¿Í»§ÀàÌá¹©Ò»¸ö»Øµ÷Íâ²¿ÀàµÄÍ¾¾¶
		 */
		public void work()
		{
			teach();
		}	
	}
	//·µ»ØÒ»¸ö·Ç¾²Ì¬ÄÚ²¿ÀàÒýÓÃ£¬ÔÊÐíÍâ²¿ÀàÍ¨¹ý¸Ã·Ç¾²Ì¬ÄÚ²¿ÀàÒýÓÃÀ´»Øµ÷Íâ²¿ÀàµÄ·½·¨
	public Teachable getCallbackReference()
	{
		return new Closure();
	}
}
