The test program should be modified to catch these exceptions, and take suitable action (e.g. print an explanatory message).
public String toString() {...}
from the java.lang.Object class
in your Matrix
class. It should return a formatted String
representation of all the elements, laid out in a way suitable for
displaying on a terminal (for example).
This string might include newline characters,
"\n", to separate rows. (Note toString
should not do any output internally--it should just return a string).
The test program should be modified to use this method whenever a matrix is to be output (you can call your toString method explicitly, or you can use "string conversion" to call it implicitly).
static public int readInt(BufferedReader in) {...}
static public float readFloat(BufferedReader in) {...}
for reading ints and floats. Detailed implementation may follow the
example given in the lectures.
Add a method
public void keyboardRead(BufferedReader in) {...}
to the Matrix class, which initializes elements of a
matrix by reading them from the keyboard.
Modify your test program to use these methods to get initial data.