Implement the class Square intended to represent n by n matrices. This class will have at least the following methods:
The constructor
public Square(int n);
which creates an n by n square initialized to the values 1,2,3,..,n2.
The copy Constructor
public Square(Square a);
which creates a faithful copy of a.
The method
public String toString();
which returns the string representation of the square.
Say we are have
Square a = new Square(3); then a.toString() will be
" 1 2 3
4 5 6
7 8 9"
The method
public void subSquares(int m);
that, assuming 1<=m<=n, will print out all the m by m subsquares of the subject
square. So in the case of the square shown above, and assuming m is 2, will print
out
1 2
4 5
2 3
5 6
4 5
7 8
5 6
8 9
The method
public static void transpose(Square a);
that changes a into its transpose, i.e. it changes our original square into
1 4 7
2 5 8
3 6 9
Extra Credit (3 points): The method
public static void diagonal(Square a);
that prints, one per line, the elements of the square a starting at top left corner
and then proceding with the the elements in the diagonals north-east.
For example, if a is
1 2 3
4 5 6
7 8 9
the output is
1
2
4
3
5
7
6
8
9
Send to the TA a case analysis for this problem: problem statement, analysis, design, implementation, and testing (i.e. in your main program you should use all the methods listed above, and then you should run your program against "reasonable" test data).