Boolean Methods
A Programming Pattern |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
void
, have
it return true
on success and false
on failureisOdd(x)
is much easier to read and understand than
((x % 2) == 1)
'M'
and 'm'
isOdd()
and
isEven()
)(x%2) == 1
in isOdd()
and (x%2) == 0
in isEven()
)isEven()
return !isOdd()
)boolean
(i.e., true
or false
)