samedi 19 décembre 2015

RandomGenerator issues

So I'm creating a new class that extends the class RandomGenerator of the acm package! and i get an error while compiling: "RandomGeneratorExtended.java:3: error: class, interface, or enum expected private rgen = RandomGenerator.getInstance();"

what is wrong?

import acm.util.*;

private RandomGenerator rgen = RandomGenerator.getInstance();

public class RandomGeneratorExtended {
    public int nextSquare(int n){
        double root= Math.sqrt(n);
        int lim = (int)root;
        int square = rgen.nextInt(0,lim);
        return square*square;
    }

    public int nextSquare(int low, int high){
        double rootlow = Math.sqrt(low);
        double roothigh = Math.sqrt(high);
        int lowlim = (int)rootlow;
        int highlim = (int)roothigh;
        int square = rgen.nextInt(lowlim, highlim);
        return square*square;
    }
}




Aucun commentaire:

Enregistrer un commentaire