Computer Science 120
Introduction to Programming
Spring 2012, Siena College
StaticCount Demo
A working demo of StaticCount will appear below. Click inside the applet to interact with it.
StaticCount BlueJ Project
Click here to download a BlueJ project for StaticCount.
StaticCount Source Code
The Java source code for StaticCount is below. Click on a file name to download it.
import objectdraw.*;
import java.awt.*;
/*
* Example StaticCount
*
* Jim Teresco, Siena College, CSIS 120, Spring 2012
*
* $Id: template.java 1777 2012-01-04 01:43:52Z terescoj $
*/
public class StaticCount extends WindowController {
public void onMousePress(Location point) {
new NumberInCircle(point, canvas);
}
}
import objectdraw.*;
/**
* Write a description of class NumberInCircle here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class NumberInCircle
{
private static final int SIZE = 50;
private static int nextNum = 0;
public NumberInCircle(Location p, DrawingCanvas c)
{
new FramedOval(p, SIZE, SIZE, c);
new Text(nextNum, p.getX()+SIZE/2, p.getY()+SIZE/2, c);
nextNum++;
}
}