整数 - 错误:".class"预期,";"预期,而不是语句



所以我对整数有一个问题。起初,我试图找到一个解决方案,因为几天,仍然不知道该怎么做。正如你所看到的,我希望给予int点:10,休息0(需要在之后给予技能点)。在技能。*我将技能名称和点数设置为private int。*, getter和setter。在概要文件。*与Skills相同,但只适用于Skills,而不是int.

三个问题:1。Int点出错。class expected, 2。每:应写成;和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);

只给构造函数/方法/函数赋值,而不给名称和类型。所以正确的做法是:

Skills skills = new Skills(10, 0, 0, 0, 0, 0);

但是,您必须检查构造函数中的顺序,以便将值指定给它们所要指定的属性。

最新更新