public long getTargetEP(long EP, int level){
EP = Math.round(10 * Math.pow(level,1.2));
return EP;
}
long currentEx = getTargetEP(EP, Level);
public long getTargetEP(long EP, int level){
EP = Math.round(10 * Math.pow(level,1.2));
return EP;
}
long currentEx = getTargetEP(EP, Level);
要让currentEx等于getTargetEP()方法里的EP参数,只需要将第一行中的EP参数改为变量即可。
修改后的代码如下:
public long getTargetEP(int level) {
long EP = Math.round(10 * Math.pow(level, 1.2));
return EP;
}
long currentEx = getTargetEP(Level);
在此修改后,getTargetEP()方法不再接受任何参数(因为EP已经在方法内定义),而是基于传入的Level计算并返回EP。然后,我们使用getTargetEP()方法来获取当前经验值currentEx,并将Level作为参数传递给它。