|
|
|
|
|
|
|
//******************************************************************
void CheckM( /* in */ char thirdChar, // 3rd input char
/* out */ Months& month, // Resulting month
/* out */ Boolean& badData ) // True if 3rd char
// bad
// Determines month beginning with M
// Precondition:
// thirdChar is assigned
// Postcondition:
// IF thirdChar == 'r' or 'y'
// badData == FALSE
// && month == MARCH, if thirdChar == 'r'
// == MAY, otherwise
// ELSE
// badData == TRUE && month is undefined
{
badData = (thirdChar != 'r' && thirdChar !='y');
if ( !badData )
if (thirdChar == 'r')
month = MARCH;
else
month = MAY;
} |
|
|
|
|
|
|
|
|
Testing and Debugging Hints |
|
|
|
|
|
|
|
|
1. Avoid using unnecessary side effects in expressions. The test |
|
|
|
 |
|
|
|
|
is less clear and more prone to error than the equivalent sequence of statements |
|
|
|
|
|