Class Reg2

java.lang.Object
  extended by Reg2

public final class Reg2
extends java.lang.Object

Implementation of an unsigned 2-bit integer type. Simulates a 2-bit register with operations modulo 4. The class follows Joshua Bloch's advice in his Item 15: minimize mutability. Joshua suggesets that one always make small value objects immutable. So, this class is immutable.

This class is used to represent the 2-bit fields in operand words.


Constructor Summary
Reg2(int x)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int getint()
           
 int hashCode()
           
 boolean iszero()
           
 java.lang.String toHexString()
          Prints out the value of this object in hexadecimal.
 java.lang.String toString()
          Prints out the value of this object in hexadecimal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Reg2

public Reg2(int x)
Method Detail

iszero

public boolean iszero()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

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

getint

public int getint()

toHexString

public java.lang.String toHexString()
Prints out the value of this object in hexadecimal. This member function was created since it is more descriptive than "toString" by explaining the base (hexadecimal) that is used in the representation.


toString

public java.lang.String toString()
Prints out the value of this object in hexadecimal. This member function simply invokes toHexString().

Overrides:
toString in class java.lang.Object