基本上,行 super(int health, intstrength, int speed, int type);
一直给我一个错误,说...
.class expected.
这是代码:
public class Pokemon {
private int health;
private int strength;
private int speed;
private int type;
public Pokemon(int health, int strength, int speed, int type) {
assert health >= 0;
assert health <= 300;
assert strength >= 1;
assert strength <= 3;
assert speed >= 1;
assert speed <= 300;
assert type >= 1;
assert type <= 3;
this.health = health;
this.strength = strength;
this.speed = speed;
this.type = type;
}
}
public class PokemonTester extends Pokemon {
PokemonTester() {
super(int health, int strength, int speed, int type);
}
{
Pokemon charizard = new Pokemon(100,2,50,1);
Pokemon blastoise = new Pokemon(150,2,150,1);
Pokemon venusaur = new Pokemon(300,2,100,1);
}
}
最佳答案
删除参数类型并将参数添加到类构造函数中。
PokemonTester(int health, int strength, int speed, int type) {
super(health, strength, speed, type);
}
关于java - 扩展类时遇到问题(不明白出了什么问题,也不明白该网站上的其他复杂解释。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35964178/