// Arup Guha
// 2/15/07
// Small test to show the mechanics of a static class variable.

public class statictest {

  // num is an instance variable, value is a static one.
  private int num;
  private static int value = 0;

  // A constructor - sets num and increments value.
  public statictest(int x) {
    num = x;
    value++;
  }

  // Returns the number of statictest objects created, which is what value stores.
  public int numObjectsCreated() {
    return value;
  }

  // Increments the instance variable num, of the current object.
  public void increment() {
    num++;
  }

  // This will allow us to see both values, one an instance variable the other
  // a static class variable.
  public String toString() {
    return "num = "+num+" value = "+value;
  }
  
  // Run a couple tests.
  public static void main(String[] args) {
  	statictest first = new statictest(3);
  	System.out.println(first);
  	statictest second = new statictest(10);
  	first.increment();
  	System.out.println(first);
  	System.out.println(second);
  }

}