Integers - error: ".class" expected , ";" expected and not a statement
Integers - error: ".class" expected , ";" expected and not a statement
所以我对整数有疑问。起初,几天以来我一直在努力寻找解决方案,但仍然不知道该怎么做。如您所见,我想给出 int points: 10 和 rest 0(稍后需要放弃技能点)。在 Skills.* 中,我给了技能名称和点 private int,this.*,getter 和 setter。在配置文件中。* 与技能相同,但仅适用于技能但没有 int。
三个问题:1. int points 出错。class 预期,2. every : 应该放在 ;和 3. 10 不是语句。
package PowerSystem.managers;
import java.util.UUID;
import java.util.Map;
import java.util.HashMap;
import PowerSystem.components.Skills;
import PowerSystem.components.Profile;
import PowerSystem.Main;
public class ProfileManager {
private Main main;
private Map<UUID, Profile> profiles = new HashMap<>();
public ProfileManager(Main main) {
this.main = main;
}
public Profile createNewProfile(Player player) {
Skills skills = new Skills(int points: 10, int health: 0, int strength: 0, int defense: 0, int speed: 0, int intelligence: 0);
Profile profile = new Profile(skills);
profiles.put(player.getUniqueId(), profile);
return profile;
}
public Profile getPlayerProfile(UUID uuid) {
return profiles.get(uuid);
}
}
这是错误的:
Skills skills = new Skills(int points: 10, int health: 0, int strength: 0, int defense: 0, int speed: 0, int intelligence: 0);
您只为 constructor/method/function 赋值,而不是名称和类型。所以正确的做法是:
Skills skills = new Skills(10, 0, 0, 0, 0, 0);
不过,您仍必须检查构造函数中的顺序,以便将值指定给它们应有的属性。
所以我对整数有疑问。起初,几天以来我一直在努力寻找解决方案,但仍然不知道该怎么做。如您所见,我想给出 int points: 10 和 rest 0(稍后需要放弃技能点)。在 Skills.* 中,我给了技能名称和点 private int,this.*,getter 和 setter。在配置文件中。* 与技能相同,但仅适用于技能但没有 int。
三个问题:1. int points 出错。class 预期,2. every : 应该放在 ;和 3. 10 不是语句。
package PowerSystem.managers;
import java.util.UUID;
import java.util.Map;
import java.util.HashMap;
import PowerSystem.components.Skills;
import PowerSystem.components.Profile;
import PowerSystem.Main;
public class ProfileManager {
private Main main;
private Map<UUID, Profile> profiles = new HashMap<>();
public ProfileManager(Main main) {
this.main = main;
}
public Profile createNewProfile(Player player) {
Skills skills = new Skills(int points: 10, int health: 0, int strength: 0, int defense: 0, int speed: 0, int intelligence: 0);
Profile profile = new Profile(skills);
profiles.put(player.getUniqueId(), profile);
return profile;
}
public Profile getPlayerProfile(UUID uuid) {
return profiles.get(uuid);
}
}
这是错误的:
Skills skills = new Skills(int points: 10, int health: 0, int strength: 0, int defense: 0, int speed: 0, int intelligence: 0);
您只为 constructor/method/function 赋值,而不是名称和类型。所以正确的做法是:
Skills skills = new Skills(10, 0, 0, 0, 0, 0);
不过,您仍必须检查构造函数中的顺序,以便将值指定给它们应有的属性。