-
Notifications
You must be signed in to change notification settings - Fork 3
1.1.6 Instructions
Each line should contain at most one statement.
Compound statements are statements that contain lists of statements enclosed in braces {}
instructions.
Return instructions should be successful only by variables, except that there is good reason to the contrary.
Statements of if-else
must meet the following formats:
if( condition ) {
/* Write Instructions Here. */
} else {
/* Write Instructions Here.
* or
* Nothing To Do.
*/
}
if( condition ) {
/* Write Instructions Here. */
} else {
/* Write Instructions Here. */
} else {
/* Write Instructions Here.
* or
*Nothing To Do.
*/
}
It should be remembered that an instruction if
should always use keys and the default behavior (else
).
for
statements should follow the following format:
for( int i = 0; i < length; i ++ ) {
/* Write Instructions Here. */
}
When using the comma operator in the initialization or update clause of a statement for
, avoid the complexity of using more than three variables.
while
statements should follow the following format:
while( condition ) {
/* Write Instructions Here. */
}
Statements do-while
should follow the following format:
do {
/* Write Instructions Here. */
} while( condition )
switch
statements should follow the following format:
switch( sum ) {
case 1:
/* Write Instructions Here. */
case 2:
/* Write Instructions Here. */
case 3:
/* Write Instructions Here. */
case 4:
/* Write Instructions Here. */
default:
/* Write Instructions Here. */
}
try-catch
statements should follow the following format:
try {
/* Write Instructions Here. */
} catch( Exception e ) {
/* Write Instructions Here. */
}
The instruction try-catch
can also be followed by, finally
, running regardless of whether or not completed the block successfully try
.
try {
/* Write Instructions Here. */
} catch( Exception e ) {
/* Write Instructions Here. */
} finally {
/* Write Instructions Here. */
}