1700441670
1700441671
interface Father{
1700441672
1700441673
public int strong();
1700441674
1700441675
}
1700441676
1700441677
//母亲
1700441678
1700441679
interface Mother{
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
//儿子比父亲强壮
[
上一页 ]
[ :1.70044167e+09 ]
[
下一页 ]