定义白富美接口,类WomanStar实现接口
interface iRich
{
void rich();
}
interface iWhite
{
void white();
}
interface ibeaut
{
void beaut();
}
class WomanStar implements iRich,iWhite,ibeaut
{
public void rich()
{
System.out.println("I‘m beaut");
}
public void white()
{
System.out.println("I‘m white");
}
public void beaut()
{
System.out.println("I‘m richer");
}
public void findlove()
{
System.out.println("Look at me,I‘m the girl who is your find");
white();
beaut();
rich();
}
}
class TuRicher
{
int money=127;
public void findlove()
{
System.out.println("I have "+money+" millions us dollars");
System.out.println("Who is rich white and beaut girl?please marry me.");
}
public void marry(WomanStar rose)
{
System.out.println("Let‘s try to love");
}
}
class MarryMe
{
public static void main(String[] args)
{
WomanStar rose =new WomanStar();
TuRicher jack =new TuRicher();
jack.findlove();
rose.findlove();
jack.marry(rose);
}
}本文出自 “yehomlab” 博客,转载请与作者联系!
原文:http://yehom.blog.51cto.com/5159116/1784229