Java Examples.

Last updated on October 19, 2008.

This page is an index into all the Java examples used in MTHSC 865 in the Fall of 2008. Many of these examples were developed during earlier offerings of this course.

  1. Simple Hello World.
  2. Simple Draw Applet Version 1.
  3. Towers of Hanoi Applet
  4. Coke Machine.

Hello World version 1.
This page displays the trivial applet with a little graphics pizzazz, including colors and fonts. It's a simple variation of the first example presented in Exploring Java by Niemeyer and Peck.

Simple Draw Applet Version 1.
This page displays an applet which uses the same shape classes demonstrated in the Shape Application examples discussed in class, except that now the shape classes have been consolidated into the package m865.shapepack and javadoc comments have been added so that the API (the Application Programming Interface) can be made available online at MTHSC 865 API. The applet includes three GUI elements: a choice object for selecting the shape, a choice object for selecting the color, and a clear button. The applet also makes use of the vector class for keeping track of the shapes.

Towers of Hanoi Applet
This applet illustrates the use of recursion to solve the Towers of Hanoi puzzle and the use of the preceding animation techniques to visually display the solution. This applet also defines a Post class which extends the m865.shapepack.Rectangle and incorporates the m865.datastructures.StackAL to conveniently mimic the physical posts with their stacks of rings.

Coke Machine.
This applet imitates a Coke Machine using a Finite State Machine, Technically, the machine in this applet is a Moore automaton.