Is there actually a specific thread to post your games? This is my first guess, and I'm not here to show off or I'll be fooling myself here as it's not the best game. I'm actually just asking for any general advice on my code such as better structuring, etc (I do know about classes but the code is short so it's pointless).
import javax.swing.JOptionPane; import java.util.Random; public class Window { public static void main(String[] args) { //hold data Random rnd = new Random(); int RandomNumber = rnd.nextInt(1001); int low = 0, high = 1000; int Number = 0; String GetText; // main loop do { GetText = JOptionPane.showInputDialog("Guess the number(" + low + "-" + high + "):"); Number = Integer.parseInt(GetText); if (Number > RandomNumber) { JOptionPane.showMessageDialog(null, "Lower!", "Guess The Number!", JOptionPane.PLAIN_MESSAGE); high = Number; } else if (Number < RandomNumber) { JOptionPane.showMessageDialog(null, "Higher!", "Guess The Number!", JOptionPane.PLAIN_MESSAGE); low = Number; } } while (Number > RandomNumber || Number < RandomNumber); JOptionPane.showMessageDialog(null, "You are a winner", "Congratulations!!!", JOptionPane.PLAIN_MESSAGE); } }
- Nicky