Class Reg4

java.lang.Object
  extended by Reg4

public final class Reg4
extends java.lang.Object

Implementation of an unsigned 4-bit integer type. Simulates a 4-bit register with operations modulo 16. 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 4-bit fields in operand words.


Constructor Summary
Reg4(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

Reg4

public Reg4(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