我是 Java 新手,我正在尝试制作一个 lvling 系统。到目前为止,我的代码是:
import java.util.*;
class Player
{
private String Name;
private int Level;
private int EXP;
int NextGoaltoLvl = 1000;
public Player(String n, int lvl, int xp)
{
Name = n;
Level = lvl;
EXP = xp;
}
public void printStats()
{
System.out.println("Name: " +Name);
System.out.println("Level: " +Level);
System.out.println("Exp: " + EXP);
}
public void addLevel(int addlvl)
{
Level += addlvl;
System.out.println("Congratulations,"+ Name +",you have leveled up to " + Level + "!");
}
public void addExp(int num)
{
EXP += num;
if (EXP == NextGoaltoLvl)
{
addLevel(1); NextGoaltoLvl += 1000; EXP = 0;
}
}
}
public class MainC
{
public static void main(String[] args)
{
Player Player01 = new Player("kert109",1,0);
for (int i = 0; i >= 10000; i++)
{
Player01.addExp(1);
}
Player01.printStats();
}
}
Player01.printStats();
我这里仍然有错误。说:语法错误,插入“}”来完成ClassBody。
我不知道出了什么问题。帮助?我曾经检查过“{”和“}”。我也清理过代码。(使用 Eclipse。)