Created
April 27, 2010 01:53
-
-
Save Cam1337/380220 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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