wrappers
Class MyInteger

java.lang.Object
  |
  +--wrappers.MyInteger

public class MyInteger
extends java.lang.Object
implements Operable, Zero, CloneableObject


Constructor Summary
MyInteger()
          MyInteger initialized to 0
MyInteger(int theValue)
          MyInteger initialized to theValue
MyInteger(java.lang.String s)
          MyInteger initialized to s
 
Method Summary
 java.lang.Object add(java.lang.Object x)
           
 java.lang.Object clone()
          make a clone
 int compareTo(java.lang.Object x)
           
 java.lang.Object decrement(java.lang.Object x)
           
 java.lang.Object divide(java.lang.Object x)
           
 boolean equals(java.lang.Object x)
           
 boolean equalsZero()
           
 int getValue()
           
 int hashCode()
           
 java.lang.Object identity()
           
 java.lang.Object increment(java.lang.Object x)
           
static MyInteger input(MyInputStream stream)
          input from the given input stream
 int intValue()
           
static void main(java.lang.String[] args)
          test program
 java.lang.Object mod(java.lang.Object x)
           
 java.lang.Object multiply(java.lang.Object x)
           
 void setValue(int theValue)
          set value to theValue
 java.lang.Object subtract(java.lang.Object x)
           
 java.lang.String toString()
           
 java.lang.Object zero()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MyInteger

public MyInteger(int theValue)
MyInteger initialized to theValue

MyInteger

public MyInteger()
MyInteger initialized to 0

MyInteger

public MyInteger(java.lang.String s)
          throws java.lang.NumberFormatException
MyInteger initialized to s
Method Detail

getValue

public int getValue()
Returns:
value of the integer

intValue

public int intValue()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setValue

public void setValue(int theValue)
set value to theValue

toString

public java.lang.String toString()
Returns:
integer in String format
Overrides:
toString in class java.lang.Object

input

public static MyInteger input(MyInputStream stream)
input from the given input stream

clone

public java.lang.Object clone()
make a clone
Specified by:
clone in interface CloneableObject
Overrides:
clone in class java.lang.Object

add

public java.lang.Object add(java.lang.Object x)
Returns:
this + x

subtract

public java.lang.Object subtract(java.lang.Object x)
Returns:
this - x

multiply

public java.lang.Object multiply(java.lang.Object x)
Returns:
this * x

divide

public java.lang.Object divide(java.lang.Object x)
Returns:
this / x

mod

public java.lang.Object mod(java.lang.Object x)
Returns:
remainder of this / x

increment

public java.lang.Object increment(java.lang.Object x)
Returns:
this incremented by x

decrement

public java.lang.Object decrement(java.lang.Object x)
Returns:
this decremented by x

zero

public java.lang.Object zero()
Specified by:
zero in interface Zero
Returns:
a new copy of 0

equalsZero

public boolean equalsZero()
Specified by:
equalsZero in interface Zero
Returns:
true iff value == 0

identity

public java.lang.Object identity()
Returns:
a new copy of 1

compareTo

public int compareTo(java.lang.Object x)
Returns:
-1 if this < x, 0 if this == x, 1 if this > x

equals

public boolean equals(java.lang.Object x)
Returns:
true iff this == x
Overrides:
equals in class java.lang.Object

main

public static void main(java.lang.String[] args)
test program