DESC 391 Assignments Fall 2009 - Assignment 4: GUI programming Print E-mail
Written by Chitu Okoli and Bilal Abdul Kader   
Friday, 19 September 2008 11:35
Article Index
DESC 391 Assignments Fall 2009
1: Interest and coins
2: Circles and dice
3: Student scores, and reservations
4: GUI programming
All Pages

Assignment 4: GUI programming

Due: Early submission is 11:59 pm on Monday December 7 (if you submit on this date, you will receive your results before the final exam)
Late submission is 11:59 pm on Friday December 11 (late penalties will apply only after this date; however, you will not receive your result before the final exam)

The purpose of this assignment is for you to begin developping GUI applications in Java. You must use a text editor to do this assignment; you must hand-code everything. You are NOT permitted to use a GUI generator that automatically creates windows for you. There are two exercises.

1. Accumulate test scores (4%)

Test Scores

Operation

·         The user enters test scores one at a time and then clicks the Enter Score button.

·         For each entered score, the application adds one to the number of scores, calculates the average score, and determines what the best score is so far. Then, it displays the number of scores, average score, and best score in the three disabled text fields. Note that although the screen does not show the total score, your application will need to store the running total in order to calculate the average properly.

·         The user can click the Clear button to reset everything to zero.

·         When the user closes the frame or clicks the Close button, the application exits.

Specifications

·         The average score is the sum of all scores divided by the number of scores.

·         Assume valid data is entered. However, you may validate the data for extra credit (see below).

·         If you have trouble getting the labels and text fields to line up properly, try adjusting the frame size. When you use the FlowLayout manager, the width of the frame affects how components you add to the frame are lined up.

Extra credit

·         Make sure that you have the application fully working before you try for extra credit!

·         For 0.5% extra credit, validate the test score to permit only a valid double value from 0 to 100. You may use the validation classes from chapter 17 (remember to cite your sources properly).

2. Enter a team lineup (8%)

Lineup

Console output

Rage 12U (home team)

 

H. Perkins, Center Field

C. Cousins, Pitcher

J. Johnson, Catcher

B. Lowe, First Base

A. Licouris, Left Field

N. Shrey, Short Stop

S. Palmore, Third Base

C. Giess, Second Base

A. Nieto, Right Field

 

Operation

·         This application lets the user enter the batting lineup for a baseball or softball team.

·         The user can enter a team name and use the radio buttons to select whether the team is the home team or the visiting team.

·         For each player, the user enters the player’s name in the text field and selects the player’s position from the combo box.

·         When the user clicks OK, the application displays the team roster on the console as shown in the console output. The order is the same order as entered by the user.

Specifications

·         The team positions in the combo boxes should offer the following choices:

Choose a selection
Pitcher
Catcher
First base
Second base
Third base
Short stop
Left field
Center field
Right field

·         Don’t worry about validating the user’s input--even a blank field is OK. However, you may validate the data for extra credit (see below).

·         You may use the BorderLayout and/or the FlowLayout to control the positioning of the labels, text fields, combo boxes, and buttons. However, for extra credit, you may use the GridBagLayout (see below).

·         Hint: Consider simplifying the solution by creating a private method that adds a label, text field, and combo box to the panel. Another option is to declare an array of text fields and an array of combo boxes rather than declaring separate controls for each player.

Extra credit

·         Make sure that you have the application fully working before you try for extra credit!

·         For 1% extra credit, use the Grid Bag layout to control the positioning of the labels, text fields, combo boxes, and buttons. However, you probably need to decide from the beginning whether to use the BorderLayout and/or FlowLayout, or whether to use the GridBagLayout. While you would get extra credit for GridBagLayout, it is harder to use, and more risky. If you're not sure you're up to the challenge, then complete the application using the simplyer layout options, and then try one of the other extra credit opportunities.

·         For 0.5% extra credit, validate the combo box selections so that the user can’t select the same position for two or more players. If the user attempts to set a combo box to a selection that’s already been assigned to a player, the combo box should immediately revert to “Choose a position.” Refer to chapter 17 for validation techniques for GUI programming.

·         For 1% extra credit, instead of printing results to a console, print results to a new frame which displays the results in a text area, and that has only one button "Close" to close the frame. However, for this output frame, the close button only closes that frame; it does not exit the entire application.

 

Submission

To submit the assignment, do the following:

  • Package your completed assignment as one zip file with two executable jar files:
    • The first jar file named "YourFirstName YourLastName Assignment 4 TestScoresApp.jar". Package it in BlueJ using Project -> Create Jar File... -> Continue (Main class: TestScoresApp; select Include source and BlueJ project files).
    • The second jar file named "YourFirstName YourLastName Assignment 4 LineupApp.jar". Package it in BlueJ using Project -> Create Jar File... -> Continue (Main class: LineupApp; select Include source and BlueJ project files).
    • Zip the two jar files into one file named "YourFirstName YourLastName Assignment 4.zip".
  • Submission deadline: E-mail the zip file to This e-mail address is being protected from spambots. You need JavaScript enabled to view it no later than 11:59 pm on Monday December 7. As long as you submit by this early deadline, you will receive your results before the final exam). However, you may submit later by 11:59 pm on Friday December 11 (late penalties will apply only after this date; however, you will not receive your result before the final exam).
  • This assignment counts as 12% of your class grade.

 



Last Updated on Tuesday, 08 December 2009 11:16