Here are chunks of code that might be helpful to you in your assignments and your various projects. Download whatever you want but if you improve something please send me a copy of the source (make sure to document it well). I'll put your rewrites here for future downloads.
First collection - 3d packages
I'll start with three pieces of code to do some 3d stuff; you might want to pirate some of it to use for assignment 3.
3dpackage This program is the most ambitious of the three. It's most of an entire 3d package modified from a book on java graphics programming but all the demo html does is to put up an array of 9 colored cubes arranged in a 3x3 grid and rotate and translate the camera around them.
Download the 31.6KB zip file.
rotatingpoints This program is pretty cheesy, and i think it's based on one of the early java applet demos from sun. It's just a bunch of 3d points connected by spokes to a central point and rotating freely around the central point. Not much there but it might be useful to somebody.
Download the 3.48KB zip file.
shiftingrectangles This program is fairly cool; it's a view inside a river of greyscale rectangles as if they were all moving toward you along the z-axis. Lots of fun for the whole family and probably lots of ideas here to steal.
Download the 14.3KB zip file.
Second collection - helper hacks
levelorder tree code provided for assignment 3.
Download the 17.7KB zip file.
string extractor provided for the parser version of assignment 4.
Download the 28.4KB zip file.
Third collection - artificial life
The emphasis in this third pair of packages is on artificial life (at least in primitive forms).
botsworld The first package is my first ever java program, written on my mac in 1995. It's fairly crummy code (i was still very much a C hacker then), but the program is neat. Check out the demo first by going to the demo page. Don't worry, this was written in java 1.0 (there was nothing else back then) so it'll run in your browser.
Here's a link to the demo and description page.
Download the 17.1KB zip file.
collective The second package is not mine. Here's the link to the site that describes it.
It's better to download the code here because (1) the code that's on the site is separated into separate source code download requests. (2) you don't get an executable until you compile it yourself. (3) the code as written doesn't work; so i've made minor modifications to get it to compile.
Download the 53.6KB zip file.
Fourth collection - image manipulation
bouncing boxes This package is rather large but very useful to learn Java tricks and the details of doing animations in Java. It's Java 1.1 so you may not be able to run it in your browser.
After unpacking it, execute the program by typing "appletviewer Bounce.html" (you will need a 1.1 jdk). You should change the default values in Bounce.html to see different animations before trying to understand the program in any detail; it's fairly advanced.
Download the 63.7KB zip file.
magnetic words This package puts up a collection of word tiles that you can move around as if they were magnetized words on a refrigerator, like the game you can buy at Borders. It's Java 1.0 so it should work in all browsers. You might find this useful in mining for interface stuff to work into your own code.
Here's a link to a demo page.
Download the 12.7KB zip file.
Fifth collection - debugging
simple debugger This program implements a simple breakpoint assert debugger. You can use it anywhere in your code, but it is particularly useful on entry and on exit from any critical method to ensure that the parameters or other variables indeed have the values, or obey the conditions, you think they should.
This is most useful when you're trying to figure out what's wrong with your code, and is invaluable in forcing you to be precise about what exactly you expect from each method coming in and going out. It's also better, and easier, than sticking in a lot of System.out.println() statements and then trying to figure out which one fired. Finally, by making the Debug methods depend on a static variable, the compiler will optimize out the calls if you set the debug variable to false and recompile, so there's no need to remove the debugging statements once you (think you) have it working.
One more point: the assertions serve to tell the next programmer to maintain your code what conditions you expect each call to obey exactly, so it's very unlikely for bugs to skitter in that way.
All in all, using an automated debugger, however primitive, is a GOOD THING.
Here's the source to the heart of the debugger. It's a little tricky because Java makes it hard to get the name of a calling method without having to explicitly put that info into the assert() calls---which would be a royal pain. Fortunately, you don't have to understand how it works to use it.
Download the 3.5KB zip file (it includes a simple test program).
thread scheduling This program forces your JVM to behave as if it is using preemptive multitasking even if it's a pathetic cooperative multitasker (otherwise know as: "give the current thread total control and let it hog the CPU if it wants to"). JVMs on the Mac and on Solaris (!!) are cooperative; Windows JVMs are preemptive. But you shouldn't take that into account---use it all the time to guarantee preemption, no matter the JVM.
It creates a single thread with high priority which regularly wakes up and thus disrupts the normal thread assignment (whichever thread was presently being processed gets booted out) which means that the thread that has been waiting the longest gets a chance to run. For a tiny performance hit (one thread that spends most of its time sleeping) you can rest easy knowing that all your threads will get an equal chance to run in the sun.
Here's the source for the simple thread scheduler.
Sixth collection - previous version of system
old datamanager is 16,409 lines of Java 1.1 code. Here's the link. Its documentation has always been available on the website here. It is 11,000 lines of HTML 3.2 code.
Use the code and documentation for inspiration and ideas only. I did not write it. It is an amalgam of the work of many hands, a few of whom were good programmers and writers and a few of whom...weren't.