Class Matrix

public class Matrix
extends Object
An instance of the Matrix class holds a 2-dimensional array of integers. A set of methods are also implemented to manipulate the 2-dimensional array. The Matrix class is used to represent the contents of each state in the state diagram.
 

Variables

o nRows
    private int nRows

        The number of rows in the 2-dimensional array

o nCols
    private int nCols

        The number of columns in the 2-dimensional array

o matrix
    public int matrix[][]

        The 2-dimensional integer array
 

Constructors

o Matrix
    public Matrix(int nRows, int nCols)

        Allocate space for the 2-dimensional array. Set the size of the array to be nRows by nCols

o Matrix
    public Matrix(Matrix m)

        Copy the contents of Matrix m
 

Methods

oisEqual
    public boolean isEqual(Matrix m)

        Returns true if Matrix m has the same elements as the current matrix
        else return false

oorMatrix
    public static Matrix orMatrix(Matrix m1, Matrix m2)

        Performs a boolean OR operation on Matrix m1 and Matrix m2 and returns the result of the OR operation
        This operation assumes that all the contents in both matrices are either 1 or 0

oor
    public int or(int v1, int v2)

        Performs a boolean OR operation on the two integers. This operation assumes that both integer values are either 1 or 0.

oshiftLeft
    public Matrix shiftLeft(int x)

        Returns a copy of the current Matrix with its contents shifted left by 'x' amount. During each shift a column of 0s is added
        to the right end of the Matrix.

oprint
    public void print()

        Prints the contents of the current Matrix onto the Java Console.

oprint
    public void print(TextPanel panel)

        Prints the contents of the Matrix onto a TextPanel object.

ogetRows
    public int getRows()

        Returns the value of nRows

ogetCols
    public int getCols()

        Returns the value of nCols



Send all bug reports and comments to tchou@elux3.cs.umass.edu