EC Assignment 99


Create a GUI application and/or applet using either AWT or Swing for a card game.
(This assignment is optional/extra credit.)

Textbook: the second half of every chapter
New concepts: GUIs, Swing, applets.


First of all, you may improve your video poker game. Ideas include:

+0.5 - Bankroll
Player starts with a certain amount and keep playing until they choose to quit or run out of cash. Possibly can choose how much they bet each turn. Cannot run into debt (negative numbers).
+0.5 - High scores
Save a file containing the top five highest bankrolls of any player that has played the game.
+0.5 - Save file
Save the player's bankroll amount in a file so they can resume play next time they start the program. (There could be one saved game for the program, or one for each player.)

Alternatively, you could create an entirely different card game. The game must be an existing game (not one you made up) and allow for significant user choice (so no War or similar games).

up to +3 - Different card game
The amount award is based on the complexity of the game: Old Maid and Go Fish are about a +1; regular poker is a +3.

However, while you can customize your card game, the main point of this assignment is to build a GUI for it. (So you must have some sort of GUI to get the above EC.)


To learn to make a Java GUI, find a good book or tutorial. I recommend starting with the Java Tutorial, particularly the Swing Tutorial

If you have questions regarding these specifications or how this assignment is graded, please let me know. I will spend a couple lab sessions discussing JOptionPanes and the very basics of creating a GUI or applet. However, outside of these GUI lab sessions, I will not answer any Swing or applet questions--the point of this EC assignment is that you learn how to do it on your own.

The amount of EC you earn will depend on the sophistication of your GUI. The following are some guidelines/ideas. Your submission must work to get credit! This means you need to include all files needed to run it, including any .html files for applets, etc.

2 points - JOptionPanes
An application that does not use the console at all but uses JOptionPanes for all input and output.
5 points - GUI Application (Text-based)
Runs much like a text-based game, only it is displayed directly within its own JFrame window or applet panel (using a non-editable TextArea for output and a text field for input, perhaps?)
6 points - GUI Application (Static display with pop-ups)
Part of the game (such as the player's hand) is displayed continuously in its own component (rather than appearing along with a printed menu). The game can be affected through components (buttons, input fields, etc) in the same panel. These components may produce pop-up/JOptionPanes to get input.
7 points - Applet or GUI Application (Embedded/direct controls)
As for "Static display of pop-ups" description, but no pop-ups are used to get input. Instead, all input is done through the same window that displays the player's hand.
+0.5 points - Close button works
Your application's X close button works.
+0.5 points - Quit Menu
The application window includes a simple working menu of the File -> Quit variety.
+1.5 points - Applet
If you do any of the above as an applet (instead of application).
+0.5 point - Applet or Application option
The same main class will run either as an application (by running its main method) or can be embedded in a webpage as an applet (because it extends Applet). (Cumulative with the +1.5 for making an applet.)
+2 points - Link to working online version of Applet
You get your applet version uploaded and running on your uhunix website.
+1 points - Console mode
It is also possible to run the game in text mode in the console window. (A command line argument will probably be required to indicate which mode to run in.)

Additional points possible for GUIs of particularly high quality.

Here is the code I showed you on GUIs in lab:

Packages and JAR files

Whatever you did for your game above, you can try using packages and a JAR file to bundle them.

+1 - Packages
First, put each of your finished classes in its own file. Then place all those classes in a package. You can use your username as the package name. (This will require you to create the appropriate directory and add the package directive to all your files.) You can have additional subpackages if you desire. Recompile everything. (If you don't do the JAR file, then zip up your directory structure to submit it.)
+1 - JAR File
Then, produce a JAR file containing all your .class and .java files.
+1 - Main-Class
You should adjust the JAR file manifest so that your application runs correctly when you execute the JAR file.

To learn more about packages and deployment using JAR files, see the Java Tutorial.

Since Tamarin won't currently accept JAR files, you'll have to email this one to your TA. Name your file UsernameA99.jar and email it following the normal email submission policies.

What to Submit

Upload your file to Tamarin (unless you created the JAR or ZIP file of packages, in which case email it to your TA instead).


Can I write a GUI for a program other than a card game?
Maybe. Talk to your TA about it first: What is the program/game? Why do you want to do it instead of a card game? What plans do you have for the GUI design?