Skip to content

Instantly share code, notes, and snippets.

@Cam1337
Created April 27, 2010 01:53
Show Gist options
  • Save Cam1337/380220 to your computer and use it in GitHub Desktop.
Save Cam1337/380220 to your computer and use it in GitHub Desktop.
//import java.util.Scanner;
import javax.swing.*;
public class MSG {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean again=true;
int l=1;
int h=100;
//JOptionPane.showInputDialog("Please pick a number (1-the number you choose)")
int m=h/2;
while(again==true){
Object[] options = { "Higher", "Lower", "Correct" };
int test = JOptionPane.showOptionDialog(null, "Is your number" + m, "BST Guessing",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
//System.out.println(test);
//JOptionPane.showMessageDialog(null, options[test]);
if(test==0){
l=m;
m=(h+l)/2;
}
if(test==1){
h=m;
m=(h+l)/2;
}
if(test==2){
again=false;
}
if(test==-1){
again=false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment