Мне в основном предлагается взять значение Unicode строки, умножить его на 10% и добавить любой уровень, который имеет текущий объект. Это разочаровывает, потому что, как оказалось, у меня есть логика, включая код, но я все равно получаю сообщение об ошибке: < 0> но был: < 8>. Любые предложения, может быть, это просто незначительный нюанс, который я должен сделать в логике, хотя я уверен, что это правильно. Примите к сведению метод getLevel, потому что там ошибкаПолучение значения unicode для первого символа в строке
public class PouchCreature implements Battleable {
private String name;
private int strength;
private int levelUps;
private int victoriesSinceLevelUp;
/**
* Standard constructor. levelUps and victoriesSinceLevelUp start at 0.
*
* @param nameIn desired name for this PouchCreature
* @param strengthIn starting strength for this PouchCreature
*/
public PouchCreature(String nameIn, int strengthIn) {
this.name = nameIn;
this.strength = strengthIn;
this.levelUps = 0;
this.victoriesSinceLevelUp = 0;
}
/**
* Copy constructor.
*
* @param other reference to the existing object which is the basis of the new one
*/
public PouchCreature(PouchCreature other) {
this.name=other.name;
this.strength=other.strength;
this.levelUps=other.levelUps;
this.victoriesSinceLevelUp=other.victoriesSinceLevelUp;
}
/**
* Getter for skill level of the PouchCreature, which is based on the
* first character of its name and the number of levelUps it has.
* Specifically, the UNICODE value of the first character in its name
* taken %10 plus the levelUps.
*
* @return skill level of the PouchCreature
*/
public int getLevel() {
int value = (int)((int)(getName().charAt(0)) * 0.1);
return value + this.levelUps;
}
Моя ошибка, это на самом деле говорило нам, чтобы взять модуль, но спасибо! – yarcenahs