Computer Science 120
Introduction to Programming
Spring 2012, Siena College
Class Examples
Class examples will be linked below. Please report any missing examples.
- Java and Objectdraw Basics
-
- TouchyWindow - basic event handlers and Text object
- ColorEvents - more graphics primitives, more event
handlers, setting colors.
- SunAndMoon - moving objects in response to events
- MouseDroppings - accessing the mouse location
- Spirograph - remembering a mouse location in an
instance variable
- Scribble - update the saved location on each drag event
- RubberBand - changing the endpoint of a line
- ClickCounter - using an int variable,
changing the contents of a Text object, constructing a string
from an int
- Conditionals and Numbers
-
- Defining Classes
-
- NiceBasketball - a fancy-looking basketball (that
just sits there)
- Arcs - examples of FramedArc and
FilledArc objects
- FancyBasketball - a class defining a fancy
basketball used by another class
- DrawBBalls - lots of instances of the basketball
- Drag2Shirts - two instances of a custom object
- House - create, change, remove a custom object
- Repetition and Active Objects
-
- RailroadClick - click to cause repetition
- Railroad - a while loop for repetition
- PerspectiveRR - railroad tracks with perspective
- GraphGrid - two while loops to create graph paper
- RandomOvalsOnClick - a while loop to draw
1000 dots with random colors and random positions on each click
- Knitting - a nested loop structure
- FlagMaker - more nested loops, private methods
- FallingBalls - a simple ActiveObject of falling objects
- VanishingScribble - a scribble program enhanced with some active objects
- PatheticPong - first attempt at a pong game, this
one with a paddle that does not interact with the ball
- LessPatheticPong - the ball can now be struck by the paddle
- Pong - the ball can now bounce off the walls
- TiltPong - communicating with the active object in pong
- Snowman - importing and using graphical images
- FallingSnow - multiple active objects
- The static Keyword
-
- StaticCount - an example of a static variable
that is not a constant
- Collections
-
- 2D Arrays
-
- TicTacToe - 2D array example
- Breakout - a breakout game using 2D arrays and
lots of other fun things
- BetterBreakout - an improved breakout game, with a turn
counter, as developed in class
- Strings and File I/O
-
- Hangman - a text-based hangman game, demonstrating
some String methods, reading a file, reading from the keyboard
- MakeOvals - create some ovals from an input file,
demonstrating FileReader/BufferedReader and
StringTokenizer
- CountWords - count up the words in a file
- Payroll - simple payroll computation
- Examples of Potential Use on Projects
-