Question: I need help writing the program called UseSuperSub which is used in the superclass called UseSuperMain. this is in java. When the main is run
I need help writing the program called UseSuperSub which is used in the superclass called UseSuperMain. this is in java. When the main is run correctly, it should print out "All ok
DO NOT MODIFY ANYTHING IN THIS FILE!! DO NOT MODIFY ANYTHING IN THIS FILE!!
public class UseSuperMain
public static void mainString args
long seed Long.parseLongargs;
int high Integer.parseIntargs;
int addThis Integer.parseIntargs;
UseSuperBase base new UseSuperBaseseed;
UseSuperSub sub new UseSuperSubseed addThis;
if basenextInthigh addThis sub.nextInthigh
System.out.printlnMismatch;
else
System.out.printlnAll ok;
public class UseSuperSub extends UseSuperBase
private int addThis;
public UseSuperSublong seed, int addAmount
TODO write your code below this comment.
You'll need to save addAmount in the
addThis instance variable, and initialize
the super class with super.
public int nextIntint high
TODO write your code below this comment.
You'll need to call the nextInt method
of the superclass, and then add addThis to
the result.
L
Download the UseSuperSub. java file, and open it in jGRASP or a text editor of your choice You will need to add code to this file so that it compiles and UseSuperMain. java ends up producing the correct output. The
comments in the file provide more details. Once you have your code working correctly, UseSuperMain. java should produce the output All ok when run.
import java.util.Random;
public class UseSuperBase
private Random random;
public UseSuperBaselong seed
random new Randomseed;
public int nextIntint high
return random.nextInthigh;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
