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.


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


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


    public boolean isEqual(Matrix m)

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

    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

    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.

    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.

    public void print()

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

    public void print(TextPanel panel)

        Prints the contents of the Matrix onto a TextPanel object.

    public int getRows()

        Returns the value of nRows

    public int getCols()

        Returns the value of nCols

Send all bug reports and comments to