Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Assignment 6 Assignment #6 Due Date: Tuesday, April 23rd Objective This assignment will help you gain practice with basic Swing components and basic event handling. Task Write an application that plays "guess the number" as follows: Your application chooses the number to be guessed by selecting an integer at random in the range 1-1000. The application then displays the following in a label: I have a number between 1 and 1000. Can you guess my number? Please enter your first guess. A JTextField should be used to input the guess. (Use an ActionEvent to activate an event on the text field) As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting "warmer", and blue indicates that the user is getting "colder". If the user has gotten no closer than the previous guess, set the background to white. Also, the background shouldn't change until the second guess, because on the first guess, there's no "previous guess" to compare with. A JLabel should display either "Too High" or "Too Low" after each guess, to help the user zero in on the correct answer. When the user gets the correct answer, "Correct!" should be displayed in the JLabel, the JTextField used for input should be changed to uneditable, and a JButton should be provided to allow the user to play the game again. If this JButton is clicked, a new random number should be generated and the input JTextField changed back to be editable (and the process starts over with a new round). Other Requirements and Notes Filename: Guess.java Note that input of guesses must be done in the JTextField, and event handling must be used. You may NOT use JOptionPane dialog boxes to get the input This should run as a Java application, so remember that your outer level container should be some sort of JFrame When you change the background color, this means the background of the whole frame (not just the text component, for instance). Any member data (static and instance variables) of classes you write should be private Make sure your code is appropriately documented and easy to read Some classes/Interfaces you'll probably want to look at: JFrame JPanel JButton JLabel JTextField ActionListener (interface) ActionEvent Demonstration General Requirements When you write source code, it should be readable and well-documented. See the link Style Guidelines for further instructions on this topic Compiling and testing Compilation instructions for various environments are on the course web site, under the heading "Compilers and Compiling Help". These include instructions for building projects in both NetBeans and Eclipse, as well as compiling from the command line on your CS account or from the DOS prompt. Make sure to test your program with a variety of different inputs. The Sample Runs above are just that -- examples, only. Never hard-code your programs to work for only one or two test cases. Your program should work and calculate the correct results for any set of valid inputs. Submitting: Program submissions should be done by using the Dropbox folder that was setup at the start of the semester. Under the folder lastname_firstname (where lastname is your last name and firstname is your first name) create a folder called asgn6. Place the Guess.java file(s) in the asgn6 folder. The file(s) will now sink with Dropbox and your submission is now recorded. Do not send program submissions through e-mail -- e-mail attachments will not be accepted as valid submissions. Do not edit or touch the files once placed in the submission folder as this will change the timestamps and could indicate a late submission. Only change the files if you want to update them. If you accidentally change/touch your files after the due date but before the late submission date use the Dropbox restore function (go to dropbox.com) to restore the file to its original timestamp. General Advice - always keep an untouched copy of your finished homework files on your computer science account, or e-mail a copy of your finished files (before the due date) to your own FSU e-mail account. This way, these files will have a time-stamp which will show when they were last worked on (a timestamp from the CS servers, or a time stamp on the FSU e-mail) and will serve as a backup in case you ever have problems with submitting files. My advice is to do this for ALL programs. For HW #6, submit only the following file: Submit the files: Guess.java