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

profilesmartstudent12

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<h)

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

        else

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

        return c;

    }


  • 5 years ago
  • 35
Answer(1)

Purchase the answer to view it

blurred-text
  • attachment
    javaP.zip
  • attachment
    VID-20210420-WA0027.mp4
  • attachment
    updatedRandomClass.zip