Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6025

Needs help in logic

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!b21g2000yqc.googlegroups.com!not-for-mail
From Eric <ehtisham@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Needs help in logic
Date Sat, 9 Jul 2011 19:05:42 -0700 (PDT)
Organization http://groups.google.com
Lines 44
Message-ID <fbfce98a-335f-4465-b8b3-bd3c4d087d1c@b21g2000yqc.googlegroups.com> (permalink)
NNTP-Posting-Host 174.254.129.188
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1310263542 12141 127.0.0.1 (10 Jul 2011 02:05:42 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Sun, 10 Jul 2011 02:05:42 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info b21g2000yqc.googlegroups.com; posting-host=174.254.129.188; posting-account=FFzo6QoAAADh42aePJcvAhdKtBt4fZOs
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order HNKRUAELSC
X-HTTP-UserAgent Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30,gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6025

Show key headers only | View raw


Hi guys: Can any one please help me in that program. I try it but
stuck in it.

ask user to enter random number between 1 to 1000 using JTextfield.
Input the user's guess in the code for a previously-registered event-
handler method or the actionPerformed method of class based on the
ActionListener
interface. For the first guess color the entire background red. If
this is the second or later guess, and they are further from the
correct number than the last guess, then color the entire background
blue. If they get the correct number then
color the background some other color than red or blue. If the user
guessed the number correctly, respond with their number, post a
congratulatory message, get a new random number, and display a JButton
to start a new game. Otherwise, to help the user close in on the
correct number, post a message, with their guessed number, whether
they are "TOO HIGH" or "TOO LOW" from the correct number, and whether
they are "WARMER" or "COLDER" (this should match the background
color). Also report the guess number of the next guess (e.g. "Enter
guess number nnn"). use a concatenated string in JLabel for these
incorrect guess messages. The process is repeated each game until the
user guesses the correct number. erase obsolete status messages.



import java.awt.*;
import javax.swing.*;
public class guessprogram {
	public static void main(String args[]){
		String title = (args.length == 0 ? "Guess Program"
		        : args[0]);
		    JFrame frame = new JFrame(title);
		    Container content = frame.getContentPane();
		    JPanel namePanel = new JPanel(new BorderLayout());
		    JLabel nameLabel = new JLabel("Enter Number: ");
		    JTextField nameTextField = new JTextField();
		    nameLabel.setLabelFor(nameTextField);
		    namePanel.add(nameLabel, BorderLayout.WEST);
		    namePanel.add(nameTextField, BorderLayout.CENTER);
		    content.add(namePanel, BorderLayout.NORTH);
			 frame.setSize(250, 150);
   		 frame.setVisible(true);
}
}

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

Needs help in logic Eric <ehtisham@gmail.com> - 2011-07-09 19:05 -0700
  Re: Needs help in logic markspace <-@.> - 2011-07-09 19:56 -0700
    Re: Needs help in logic lewbloch <lewbloch@gmail.com> - 2011-07-11 11:18 -0700
  Re: Needs help in logic Roedy Green <see_website@mindprod.com.invalid> - 2011-07-10 02:02 -0700

csiph-web