I can not compile this class and I can not detect the error

0
package ex2;

import java.util.Random;

public class ExpSys {
    private Random ran;
    int Level = 1;
    int Exp_Base = 10;
    int Exp = 0;
    int Exp_Max = 0;

    public ExpSys() {
        this.ran = new Random();
        Exp_Max = (Exp_Base * Level) + (ran.nextInt((Level * 0.05)) + (Level * 0.01));
    }

    public void gainExp() {
        for (int i = 0; i <= 10; i++) {
            System.out.println("Nivel   : " + Level + "Exp necesaria   : " +         Exp_Max + "\nExp actual   : " + Exp);
            int expObt = 1 + ran.nextInt((Level * 2)) + 1;
            Exp += expObt;
            System.out.println("============\nGanaste: " + expObt + "============");
            Level += (Exp <= Exp_Max) ? LevelUp() : 0;
        }
    }

    private int LevelUp() {
        //growStats();
        System.out.println("Subiste al nivel: " + Level + 1);
        Exp_Max = (Exp_Base * Level) + (ran.nextInt((Level * 0.05)) + (Level * 0.01));
        return 1;
    }
}
    
asked by Berishten VanCheese 18.03.2018 в 18:07
source

1 answer

2

I have copied your code and I have debugged it. It seems that you try to save an operation that returns decimals in an INT variable. I attached a photo with the exception. Greetings

    
answered by 18.03.2018 / 18:51
source