Computer Science 252
Problem Solving with Java
Fall 2013, The College of Saint Rose
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 which is used by another class to play our basketball game
- DrawBBalls - lots of instances of the basketball
- Drag2Shirts - two instances of a custom object
- CarsExample - in-class example of another custom object
- Repetition and Active Objects
-
- Java Interfaces
-
- Swing
-
- Recursive Structures and Methods
-
- NestedSquaresLoop - loop-based nested squares
- NestedSquaresRec - recursive constructor for nested squares
- NestedSquaresDrag - drag around nested squares using recursive data structure and recursive move method
- NestedSquaresSizes - drag around nested squares but with multiple sizes, ability to set color or get info using recursive methods
- Powers - compute powers (base raised to an
exponent) iteratively and recursively
- SimplestRecScribbler - defining a recursive
scribble data structure
- SimpleRecScribbler - using the recursive scribble
data structures
- RecWoodPile - a stack of wood to which we can add
logs or remove logs only from the top
- ChainReaction - another recursive data structure, combined with some animation
- RecScribbler - adding a list of scribbles to allow dragging/coloring of all existing scribbles
- Broccoli - a recursive structure representing a piece of broccoli
- BroccoliBetter - a recursive structure representing a piece of broccoli using an interface to simplify code
- LivingFractal - build a fractal shape recursively with an active object
- Collections
-
- Concurrency
-
- ATM1 - demonstrating the dangers of concurrency
- ATM2 - demonstrating the dangers of concurrency
- ATM3 - demonstrating how to avoid the dangers of concurrency