Comp3200 object-oriented programing assignment define a


Object-Oriented Programing Assignment

Introduction -

A logical matrix or (0, 1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pair of finite sets. If R is a binary relation between the finite indexed sets X and Y (so R ⊆ X × Y), then R can be represented by the logical matrix M whose row and column indices index the elements of X and Y, respectively, such that the entries of M are defined by:

           1  (xi, yj) ∈ R

M i,j =

            0  (xi, yj) ∉ R

In order to designate the row and column numbers of the matrix, the sets X and Y are indexed with positive integers: i ranges from 1 to the cardinality (size) of X and j ranges from 1 to the cardinality of Y.

Example:

The binary relation R on the set {1, 2, 3, 4} is defined so that aRb holds if and only if a divides b evenly, with no remainder. For example, 2R4 holds because 2 divides 4 without leaving a remainder, but 3R4 does not hold because when 3 divides 4 there is a remainder of 1. The following set is the set of pairs for which the relation R holds.

{(0,0), (1,0), (2,0), (3,0), (4,0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

The corresponding representation as a Boolean matrix is:

1092_Figure.png

Define a class (called LogMat) to represent logical matrix of any binary relation as explained previously.

A. The class has three member variables: matrix(as dynamic 2-D array), rowSize and columnSize.

B. Provide a default constructor with default parameter to initialize an empty matrix to 0 with a maximum of 10 X 10.

C. Overload the stream extraction (>>) to read the R from input file where the format of the input file as

{(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)} for each R.

D. Overload the stream insertion (<<) to display the matrix on the screen.

E. Overload the (==) operator to check if two sets are equal.

F. Overload the plus (+) operator to return the combination between two sets. For example if A and B are sets then A + B should return a set that contains all the elements in either or both of the sets.

G. Provide functions that should/must be in the class.

H. Write main program that:

i. Create an input file for each of the below relations:

- aRb holds if and only if a divides b evenly, with no remainder

- aRb holds if and only if the sum of a+b is an even number.

ii. Each set should be in format as mentioned in part C.

iii. Create at least one object for each relation.

iv. Test the operators the overloaded operators.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Comp3200 object-oriented programing assignment define a
Reference No:- TGS02168552

Expected delivery within 24 Hours