为不同的班级制作独特的统计数据

时间:2018-01-24 18:44:14

标签: java inheritance subclassing

我想要做的是我有一个名为" Unit"它描述了Warhammer TableTop游戏中一个单元的一般统计数据,以及一个子类,它具有针对该类初始化的更具体的统计数据,然后试图查看我是否可以成功编写攻击阶段(?)。

public class Unit {

    protected int bravery;
    protected int wounds;
    protected int movementInInches;
    protected int save;

    protected int range;
    protected int attacks;
    protected int successfulHit;
    protected int successfulWound;
    protected int rend;
    protected int damageDealt;

    protected int unitSize;

    public Unit(int n) {
        n = unitSize;
    }

    public void attack(Unit a, Unit b) {

    }
}


public class Greatswords extends Unit {

    public int bravery = 6;
    public int wounds= 1;
    public int movementInInches = 5;
    public int save = 4;

    public int range = 1;
    public int attacks = 2;
    public int successfulHit = 4;
    public int successfulWound = 3;
    public int rend = 1;
    public int damageDealt = 1;

    public Greatswords(int n) {
        super(n);
    }
}


public class BlackOrcs extends Unit {

    public int bravery = 6;
    public int wounds = 2;
    public int movementInInches = 4;
    public int save = 4;

    public int range = 1;
    public int attacks = 2;
    public int successfulHit = 4;
    public int successfulWound = 3;
    public int rend = 1;
    public int damageDealt = 1;

    public BlackOrcs(int n) {
        super(n);
    }
}

显然,我还没有进入攻击阶段,我有点想自己解决这个问题,因为我只是将其视为实践。我想知道的是,如果硬编码像这样的示例单位是"正确"或者是否有正确的方法。

0 个答案:

没有答案