public class GuessGameBean {
private int theNumber, min, max;
private void init() {
min = 1;
max = 100;
theNumber = new java.util.Random().nextInt( 100 ) + 1;
}
public GuessGameBean() { init(); }
public int getMin() { return min; }
public int getMax() { return max; }
public void setGuess( String inString ) {
System.out.println( "setGuess: min.ans.max-in " + min + "." + theNumber
+ "." + max + "-" + inString );
if (inString == null) return;
int input = Integer.parseInt( inString );
if (input < theNumber) {
if (input > min) min = input;
} else if (input > theNumber) {
if (input < max) max = input;
} else
min = max = input;
}
public String getResults() {
if (min == max) {
init();
return "Sirens!! Confetti!! Fireworks!!Go again";
} else
return "";
} }