1700441680
1700441681
public int kind();
1700441682
1700441683
}
1700441684
1700441685
其中strong和kind的返回值表示强壮和温柔的指数,指数越高强壮度和温柔度也就越高,这与在游戏中设置人物的属性值是一样的。我们继续来看父亲、母亲这两个实现:
1700441686
1700441687
class FatherImpl implements Father{
1700441688
1700441689
//父亲的强壮指数是8
1700441690
1700441691
public int strong(){
1700441692
1700441693
return 8;
1700441694
1700441695
}
1700441696
1700441697
}
1700441698
1700441699
class MotherImpl implements Mother{
1700441700
1700441701
//母亲的温柔指数是8
1700441702
1700441703
public int kind(){
1700441704
1700441705
return 8;
1700441706
1700441707
}
1700441708
1700441709
}
1700441710
1700441711
父亲强壮指数是8,母亲温柔指数也是8,门当户对,那他们生的儿子、女儿一定更优秀了,我们先来看儿子类,代码如下:
1700441712
1700441713
class Son extends FatherImpl implements Mother{
1700441714
1700441715
@Override
1700441716
1700441717
public int strong(){
1700441718
1700441719
//儿子比父亲强壮
1700441720
1700441721
return super.strong()+1;
1700441722
1700441723
}
1700441724
1700441725
@Override
1700441726
1700441727
public int kind(){
1700441728
1700441729
return new MotherSpecial().kind();
[
上一页 ]
[ :1.70044168e+09 ]
[
下一页 ]