CST2641 Advanced Java I
Lab Week 5


Exercises

Exercise 8.1

In chapter 7 of Java for Students, there is a Digital Combination Safe problem.  This is a variation of the problem in the book.   Write a program to act as the digital combination lock for a safe.  Create ten buttons, representing the numbers 0 through 9.  The user clicks on the buttons, attempting to guess the correct numbers (example:  638)  The program remains unhelpfully quiet until the correct buttons are pressed consecutively.  When the correct sequence in pressed, print a message that the combination is valid.

Also have a button that allows the user to change the safe's combination only after they have entered the original combination correctly.  This is similar to the way users are allowed to change passwords for other computer applications.

Have graphics on the buttons instead of just plain text.

The program needs to be a stand alone application written using swing.

Exercise 8.2 (Extra Credit)

Take the program above,  turn it back into an applet, and make it run within a web page, and continue using swing.  It must be launched within a web browser (not from the run Java applet menu selection in Textpad).

Note:  It may be quite difficult to get graphics on the buttons when it is an applet.  Extra extra credit if you can use graphics in an applet that runs in a web browser.  :-)