24. A Simple Demonstration
A Simple Demonstration
So far we have learned some of the essential basics of Java, and about some of the essential Java classes and their use. While what we've learned is not a great deal in the scheme of things, it is nonetheless still quite useful. There's an awful lot you can do with just these few classes and techniques. Even just the JOptionPane class allows us to build an application that uses the GUI for most of its interaction with the user.
Accessible from the links below in the page are two Java classes that in addition to the standard java.lang classes use only:
- the version of our Die class built for Ex. 6 B
- the console
This game called Sevens displays the rules of the game in the console on startup, and then displays the progressive game scores in the console thereafter. All other interactions with the user take place through an instantiation of the JOptionPane class. To play the game, you need to download the two files below and save them in a folder. Access the folder with the console, and then type java Sevens to run the game. Note: You will need to have j2sdk1.4.2_03 or later to run the game.
Once you have played the game and seen how it works, you might like to take up the challenge of building the game - or something similar - for yourself!