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 main(String[] args){
long seed = Long.parseLong(args[0]);
int high = Integer.parseInt(args[1]);
int addThis = Integer.parseInt(args[2]);
UseSuperBase base = new UseSuperBase(seed);
UseSuperSub sub = new UseSuperSub(seed, addThis);
if (base.nextInt(high)+ addThis != sub.nextInt(high)){
System.out.println("Mismatch!");
} else {
System.out.println("All ok");
}
}
} public class UseSuperSub extends UseSuperBase {
private int addThis;
public UseSuperSub(long 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 nextInt(int 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 UseSuperBase(long seed){
random = new Random(seed);
}
public int nextInt(int high){
return random.nextInt(high);
}
}
I need help writing the program called

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!