package ParentsTeachChild;
public class Test
{
public static void main(String[] args)
{
Child child = new Child("小明", true);
Father father = new Father("望子成龙的爸爸", child);
Mother mother = new Mother("溺爱的妈妈", child);
Thread fThread = new Thread(father);
Thread mThread = new Thread(mother);
fThread.setDaemon(true);
fThread.start();
mThread.start();
}
}
package ParentsTeachChild;
public class Child
{
private int blood;
private String name;
private boolean isNaughty;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean isNaughty()
{
return isNaughty;
}
public void setNaughty(boolean isNaughty)
{
this.isNaughty = isNaughty;
}
public Child(String name, boolean isNaughty)
{
super();
this.name = name;
this.isNaughty = isNaughty;
System.out
.println("==================================================");
System.out
.println(" "
+ this.name + "很调皮!");
System.out
.println("==================================================");
this.blood = 100;
}
public int getBlood()
{
return blood;
}
public void setBlood(int blood)
{
this.blood = blood;
}
}