Question
1. Create a subclass of Random class. Your subclass will have the following methods and add one more your own method. public char nextChar() public
1. Create a subclass of Random class. Your subclass will have the following methods and add one more your own method.
public char nextChar() public char nextChar(char l, char h) public int nextSequence(int l, int h)
2. Create a main program to test all the above methods in the subclass. Please refer to the skeleton file(newRandomGenerator_Skeleton.java).
public class newRandomGenerator_Skeleton { public static void main(String[] args) {
System.out.println(); System.out.println("nextChar():"); for (int i=0; i<5;i++){ char c1 = rand.nextChar(); System.out.println(c1); }
System.out.println(); System.out.println("nextChar('A','C'):"); for (int i=0; i<5;i++){ char c2 = rand.nextChar('A','C'); System.out.println(c2); }
System.out.println(); System.out.println("nextChar('Y','C'):"); for (int i=0; i<5;i++){ char c2 = rand.nextChar('Y','C'); System.out.println(c2); }
System.out.println(); System.out.println("nextSequence(1,6):"); for (int i=0; i<5;i++){ int ns = rand.nextSequence(1,6); System.out.println(ns); }
} }
[Sample Output]
----jGRASP exec: java newRandomGenerator_Skeleton
nextChar(): Z K J U O
nextChar('A','C'): C C B C A
nextChar('Y','C'): Y B Y A C
nextSequence(1,6): 2 1 4 5 2
----jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started