import java.lang.reflect.Field;
public class A //演示成都春熙路上,窈窕淑女,方丈好球
{
public static void main(String[] args) throws SecurityException, NoSuchFieldException
{
IPrettyGirls pg=new PrettyGirl("安娜");
Men man=new AMan(pg,"智障禅师");
pg.goodlooks();
pg.goodshapes();
pg.goodtemperament();
pg.callloudly();
man.findgirl();
// 打开注释 Field fi =AMan.class.getSuperclass().getField("prettygirl");
// System.out.println(fi);
}
}
interface IPrettyGirls //的标准接口
{
public void goodlooks(); //相貌好
public void goodshapes(); //身材好
public void goodtemperament(); //脾气好
public void callloudly(); //不挑逗也不算美女
}
class PrettyGirl implements IPrettyGirls //接口实现类
{
protected static String name; //定义字符串
public PrettyGirl(String name) //构造函数初始化美女名字
{
this.name =name;
}
public void goodlooks() //重写接口方法
{
System.out.println("我好漂亮啊!!");
}
public void goodshapes() //重写接口方法
{
System.out.println("我好苗条啊!!");
}
public void goodtemperament() //重写接口方法
{
System.out.println("我好温柔啊!!");
}
public void callloudly() //重写接口方法
{
System.out.println("谁来娶我呀!!");
}
}
abstract class Men //人抽象类
{
public IPrettyGirls prettygirl;
static String name;
public Men(IPrettyGirls prettygirl,String name) //传入一个美女引用,让男人一开始就有追求目标
{
this.prettygirl=prettygirl;
this.name=name;
}
public abstract void findgirl(); //追求女人
}
class AMan extends Men //人扩展类
{
public AMan(IPrettyGirls prettygirl,String name)
{
super( prettygirl,name);
}
public void findgirl()
{
System.out.println(AMan.name+"从容道:"+PrettyGirl.name+"不要喊别人了,你就从了老衲吧!!");
}
}
|