STUDENT-ORIENTED CODE SAMPLES

Teaching samples are not always the best code. because they are designed to illustrate one and only one point based on the students' current knowledge.  For every snippet posted on a site, a better implementation is in the next chapter, in the next book, or on the next Web page.   Better code samples are available on the Internet that have been authored by developers with a business audience, to illustrate how to use modules within an API or SDK. Some of my favorites are included in the Links page.


Two-Dimensional Arrays in Java

This program is a rudimentary exploration of 2-dimensional arrays.  It also introduces the concept of multiple windows, which is common for Java programs.  It requires a class named DrawingPanel.java, which can be downloaded from the site named http://www.buildingjavaprograms.com/supplements.shtml. The site accompanies the textbook "Building Java Programs", which is the introductory programming textbook  at UW Seattle.

After the students explore jFrame and jPanel objects, the ArayMax2 program can be written to extend those classes for a sleeker look.
araymax2.java
File Size: 16 kb
File Type: java
Download File


2D Graphical Arrays in Java

This program explores multiple windows for Java programs; it was intended to be an extension of the araymax program, but the architecture imposed by the Java Virtual Machine meant a complete rewrite.   The new program uses JFrame and JPanel objects to draw shapes in a 2-dimensional array on a screen.

The rewrite no longer requires the DrawPanel object; instead, each shape that can be drawn on the screen is its own class, and it coordinates with the JPanel object extension.
framemax.zip
File Size: 8 kb
File Type: zip
Download File
Some presentations include images that were included with purchased software.