40分,简单问题---关于抽象类引用
Soldier 和 Monster 都是抽像类,想随机的产生soldier 和monster 的级别,可这样出错了,大虾进来看看,
Soldier soldier;
switch (tslevel + 1) {
case 1:
soldier = new WeakSoldier(((tslevel + 1) * 10 + 5),
tslevel + 1);
break;
case 2:
soldier = new NormalSoldier(((tslevel + 1) * 10 + 5),
tslevel + 1);
break;
case 3:
soldier = new StrongSoldier(((tslevel + 1) * 10 + 5), tslevel + 1);
}
/**
* 随机产生怪
*/
Monster monster;
switch (tmlevel + 1) {
case 1:
monster = new BabyMonster(((tslevel + 1) * 10), tslevel + 1);
break;
case 2:
monster = new NormalMonster(((tslevel + 1) * 10), tslevel + 1);
break;
case 3:
monster = new FinalMonster(((tslevel + 1) * 10), tslevel + 1);
break;
}