Question: Try this oddball problem. The code below includes a live object from the Surprise class, called mystery. public class Surprise{ private String secret; private int
Try this oddball problem. The code below includes a live object from the Surprise class, called mystery.
public class Surprise{ private String secret; private int n; private int m; public Surprise(int a, int b, String s){ n = a; m = b; secret = s; } public int getN(){return n;} public int getM(){return m;} public void setN(int a){n = a;} public void setM(int b){m = b;} public void revealSecret(){ /* body of method is top secret! */ } } Surprise objects have two private instance variables, n and m. The object's secret is revealed only when the values of n and m are equal. Using commands from the Surprise class, figure out a way to get the mystery object to reveal its secret. The revealSecret method will write the secret to the console, but only when n and m are equal. Note: to get a feel for the problem, see what happens when you make no changes at all to the mystery object (in other words, get the problem wrong!). That is, simply try to reveal the secret immediately using the revealSecret method. Then, try this method after you use commands from the Surprise class to set n and m to the same value. Enter your code in the box below.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
