Code:
public TestScores (double [] s) throws IllegalArgumentException {
scores = new double [s.length];
for (int i=0; i<scores.length; i++) scores[i] = s[i];
for (int i=0; i<scores.length; i++)
if (s[i]<0 || s[i]>100) throw new IllegalArgumentException ();
}
public TestScores (double [] s) throws IllegalArgumentException {
scores = new double [s.length];
for (int i=0; i<scores.length; i++) scores[i] = s[i];
for (int i=0; i<scores.length; i++)
if (s[i]<0 || s[i]>100) throw new IllegalArgumentException ();
}
U test programu izuzetak se hvata sa:
Code:
catch (IllegalArgumentException e)
{
System.out.println("Invalid score found.\n" + e.getMessage());
}
catch (IllegalArgumentException e)
{
System.out.println("Invalid score found.\n" + e.getMessage());
}
Problem je u getMessage() metodi, ona treba da ispishe s koje ne zadovoljava oseg od 0 do 100. Kako?