CS111, Fall 2009

(Back to the main page)

Useful links

Code

Here’s the source for most of the demo programs we’ve covered in detail in class. The lecture archives (click on the lecture heading) contain all files from each lecture, including supplementals like Graphics.java or IO.java; otherwise, if it needs Graphics.java, it’s marked with a G, and if it needs IO.java, it’s marked with an I.

IO.java
The IO module used in most assignments.
Graphics.javaUpdated 2009/10/22
Graphics module. This is alpha, and may still have bugs. If it breaks, it breaks.

Lecture 4:
ConvertThings.java (I)
Converting pounds/kilograms, with loops.
Circle1.java (G)
Drawing circles, first version: one color, one point at a time.
Circle2.java (G)
Drawing circles, second version: grayscale, one point at a time.
Circle3.java (G)
Drawing circles, third version (mentioned in class): grayscale, four points at a time.
Circle4.java (G)
Drawing circles, fourth version (not covered in class, here for completeness): grayscale, eight points at a time. Pretty.

Lecture 6:
Calculator1.java (I)
Original version of the calculator, no loops.
Calculator2.java (I)
Enhanced version of the calculator, with loops and new lemon-fresh scent.

Lecture 7:
IncDecOperatorDemo.java
Quick and dirty demo of the ++ and -- operators in Java.
ForLoopPieces.java
Similarly fast and filthy demo of breaking a for loop into two pieces. Counts from 1 to 20, sneezing after 10.
DoubleForDemo.java
Using a for loop with two initializations and updates. Prints out powers of two from 0 to 30.
ASCIIBox.java (I)
ASCII-art box; demonstrates for.
ASCIICircle.java (I)
ASCII-art circle. Not covered in class but a useful toy for experimenting with loops.
SineWaves.java (G)
Sine waves; demonstrates for with doubles.
Lecture 8:
Magic8Ball.java (I)
A horribly simple Magic 8-Ball (<dont-sue>™ of Mattel</dont-sue>) demo program. Shows how to use a switch.
Lecture 9:
CommandPrompt.java (I)
A quick command-prompt application demonstrating equals with strings. Real command prompts work similarly to this.
ReverseString.java (I)
Reverses a string. Demonstrates length() and charAt, as well as iterating over the characters in a string.
IntToString.java (I)
Manually converts an integer to a string.
Lecture 10:
SplitWords.java (I)
Splits a string into words separated by whitespace.
FindExtension.java (I)
Finds the extension of a filename or path fed to it.
Lecture 12:
Interpreter.java (I)
Interprets a terribly simple programming language.
Lecture 13:
Hangman.java (I)
Plays the game of Hangman.
Add2BigInts.java (I)
Adds two integers of arbitrary length, using strings.
Lecture 15:
PlotRunTimes.java (G)
Plots the run times of insertion and selection sorts, and demonstrates their O(n²) run time.
Lectures 18 and 19:
SLList.java and SLNode.java
Singly-linked list implementation, complete and replete with merge sort, selection sort, and insertion sort implementations.
DLList.java and DLNode.java
Doubly-linked list implementation.