Witam.
Mam dwa pakiety szyfrowanie i View importuję do szyfrowania klasy View
import View.View;
i próbuję wywołać metodę z View
try
{
View.writeTheMatrix(matrix,matrixSize);
}
// if matrix is empty
catch (MatrixException e)
{
System.out.println(e.getMessage());
}
zawartość View :
package View;
//import szyfrowanie.Szyfrowanie;
class MatrixException extends Exception
{
/** Constructor without parametric */
public MatrixException()
{
super();
}
/** Constructor
* @param message display message
*/
public MatrixException(String message)
{
super(message);
}
}
public final class View
{
/**
* The method which is printing text in console
* @param tab which is matrix
* @param matrixSize which is size of matrix
* @exception MatrixException when matrix is empty
*/
public static void writeTheMatrix(char tab[][], int matrixSize) throws MatrixException
{
/** variable which store number of matrix column */
int column = 0;
/** variable which store number of matrix row */
int row = 0;
/** variable which stores information about an error */
boolean error = false;
// checking whether a matrix is empty
if(matrixSize == 1)
{
error = true;
throw new MatrixException("Matrix is empty!!!");
}
// if matrix is empty, close program
if(error ==true)
{
System.exit(0);
}
// if matrix is not empty, print matrix
while(row<matrixSize)
{
while(column<matrixSize)
{
System.out.print(tab[row][column]);
column++;
}
column = 0;
row++;
}
}
}
Niestety to nie działa i nie wiem dlaczego, wyskakuje error :unreported exception MatrixException; must be caught or declared to be thrown
ale przecież mam przechwycenie wyjątku...
Czy ktoś mógłby mi wytłumaczyć co robię źle ?