1 package org.enhydra.shark.wrd; 2 3 import java.io.Serializable ; 4 5 public class Counter implements Serializable , Cloneable { 6 7 private int no; 8 9 public void increment () { 10 no++; 11 } 12 13 public void decrement () { 14 no--; 15 } 16 17 public int value () { 18 return no; 19 } 20 21 public void reset () { 22 no=0; 23 } 24 25 public String toString () { 26 return "I'm counter and my value is "+no; 27 } 28 29 public Object clone () { 30 try { 31 return super.clone(); 32 } catch (Exception ex) { 33 return null; 34 } 35 } 36 37 public boolean equals (Object obj) { 38 if (!(obj instanceof Counter)) return false; 39 Counter cnt=(Counter)obj; 40 if (cnt.no==no) { 41 return true; 42 } else { 43 return false; 44 } 45 } 46 } 47 | Popular Tags |