Sample Modules

ICS-33: Intermediate Programming


The following is a list of zipped Eclipse project files (more might be added during the quarter). Please feel free to download, unzip, run, and study these scripts (both their code and their run-time behavior). Programmers gain tremendous insight into all facets of programming by studying the code of other programmers (especially those with more experience; and I am happy to improve my code based on your observations -nothing is perfect). A good programmer typically makes elegant use of the required language features, resulting in smaller, more elegant code.

All downloadable projects are listed alphabetically; you can also search this page for keywords. All are zip files, so unzip them first. Most project files require the Download: standard course library which contains a variety of useful modules. If you followed the Eclipse installation instructions, you should have already created the courselib folder in your workspace and populated it with these modules.


Download: Collatz Conjecture
The Collatz conjecture states: starting with any positive number, repeat the process "If it is even, halve it; if it is odd, multiply it by three and add one" and eventually the remaining value reduces to one. No one has been able to prove this conjecture, but a short script allows us to investigate it (and others have examined billions of different values and found no counterexamples). It is interesting to observe the number of cycles required to reduce the starting number to 1, looking for a pattern. This script is highlighted in the debugger handout.

Download: Craps Statistics
This script prompts the user for the number of craps games to play (craps is a dice game whose rules are explained in the block comment at the top of this script). It then simulates that many games of craps, printing the number (and percentage) of wins, losses, dice throws (and average dice throws per game), elapsed time, and game playing speed. This script is used inthe problem set for the debugger handout.

Download: Regular Expression Tester
This script is a complicated driver for testing methods in the re (Regular Expression) module. There are boths simple and complex features dealing with entering patterns and testing for matches, searches, finds, substitutes (with replacements), and splits. Regular Expressions are tersely illustrated in a lecture.