Handle Invalid Scale Values
Learn to handle invalid scale values.
A too small scale value
What should happen if the program user enters an invalid number? ImageResizer
will need to show a message and put the cursor in the field that has the invalid number.
Add a method to check for a valid number that meets a minimum value.
- Add a private method called
isValid()
. It should take two parameters, a string calleds
and an integer calledminVal
, and return a boolean. - Create a boolean called
valid
initialized to false. - Create an integer called
i
set to the integer value ofs
using Integer’sparseInt()
method. - If
i
is greater than or equal tominValue
, setvalid
to true. - Return
valid
.
...
______________ isValid(____________) {
________ valid = __________;
________ i = _____________(____);
if (_____________) {
valid = ________;
}
return _________;
}
...
Get hands-on with 1200+ tech skills courses.