Upgrade the Java built-in class ‘Random’ by using the inheritance concept

The intructor comments:

 
Wrong implementation. 

nextChar (‘X’ , ‘C’)   

must be one of ‘X’, ‘Y’, ‘Z’, ‘A’, ‘B’, ‘C’ 

Below is the code for the function nextChar: 

char nextChar(){

        char c=(char)nextInt(65,90);            // ‘A’ to ‘Z’ ASCII code is 65-90 finding random ASCII code in this range

        return c;

    }

    char nextChar(char low,char high){

        int l=(int)low;

        int h=(int) high;

        char c=’A’;

        if(l

        c=(char)nextInt(l,h);                    // finding random ASCII code between given range

        else

            c=(char)nextInt(h,l);

        return c;

    }

Tags: No tags