// A basic counter object that doesn't use synchronization or promise // that its methods are atomic. /****************************************************************************** CHANGE LOG. 1 Feb 99: Creation. ******************************************************************************/ class Counter { private int n; Counter() { n = 0; } Counter(int k) { n = k; } int get() { return n; } void set(int k) { n = k; } int preincr() { return ++n; } int postincr() { return n++; } int predecr() { return --n; } int postdecr() { return n--; } }