1 public class Value { 2 protected int value; 3 4 public Value(int value) { 5 this.value = value; 6 } 7 8 public int getValue() { 9 return this.value; 10 } 11 12 public void setValue(int value) { 13 this.value = value; 14 } 15 16 public boolean isPositive() { 17 return this.value > 0; 18 } 19 20 public int compare(int value) { 21 if (value < this.value) { 22 return -1; 23 } else if (value == this.value) { 24 return 0; 25 } else { 26 return 1; 27 } 28 } 29 30 public int add(int value) { 31 return this.value + value; 32 } 33 34 public Value newValue() { 35 return new Value(this.getValue()); 36 } 37 } 38 39 // vim: tabstop=4 expandtab shiftwidth=4