Skip to content

Commit

Permalink
improved parameter checks in constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Jun 4, 2020
1 parent 45fc975 commit 0d0333d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public final class JumpObjectiveFunction
*/
public JumpObjectiveFunction(final int _n, final int _k) {
super(_n);
if ((_k > 0) && (_k >= (_n >>> 1))) {
if ((_k <= 1) || (_k >= (_n >>> 1))) {
throw new IllegalArgumentException(
"k must be greater than 0 and less than half of n, but we got k=" //$NON-NLS-1$
"k must be greater than 1 and less than half of n, but we got k=" //$NON-NLS-1$
+ _k + " and n=" + _n);//$NON-NLS-1$
}
this.k = _k;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public final class PlateauObjectiveFunction
*/
public PlateauObjectiveFunction(final int _n, final int _k) {
super(_n);
if ((_k > 0) && (_k >= (_n >>> 1))) {
if ((_k <= 1) || (_k >= (_n >>> 1))) {
throw new IllegalArgumentException(
"k must be greater than 0 and less than half of n, but we got k=" //$NON-NLS-1$
"k must be greater than 1 and less than half of n, but we got k=" //$NON-NLS-1$
+ _k + " and n=" + _n);//$NON-NLS-1$
}
this.k = _k;
Expand Down

0 comments on commit 0d0333d

Please sign in to comment.