| Line 1: |
Line 1: |
| − | A '''loop''' in [[Computer Programming]] is a section of instructions which are repeated - either endlessly or until a certain expected state occurs. | + | A '''loop''' in [[computer programming]] is a section of instructions which are repeated - either endlessly or until a certain expected state occurs. |
| | A common error made by novice programmers is to program an infinite loop, i.e., one that never ends despite the programmer's hopes. | | A common error made by novice programmers is to program an infinite loop, i.e., one that never ends despite the programmer's hopes. |
| | | | |
| Line 6: |
Line 6: |
| | This trivial example prints out the first five integers: | | This trivial example prints out the first five integers: |
| | FOR I = 1 TO 5 | | FOR I = 1 TO 5 |
| − | PRINT I
| + | PRINT I |
| | NEXT I | | NEXT I |
| | | | |
| Line 13: |
Line 13: |
| | for (int i = 0; i < 5; i++) { | | for (int i = 0; i < 5; i++) { |
| | | | |
| − | System.out.println( employee(i) );
| + | System.out.println( employee(i) ); |
| | | | |
| | } | | } |
| Line 19: |
Line 19: |
| | A while loop doesn't need a counter: | | A while loop doesn't need a counter: |
| | | | |
| − | while ( boxes.getCount() > 0 ) { | + | while ( shipment.hasItems() > 0 ) { |
| | | | |
| − | Item box = boxes.getFirst();
| + | Item box = shipment.getFirst(); |
| − | box.shipToCustomer();
| + | box.shipToCustomer(); |
| | | | |
| − | boxes.remove(box);
| + | shipment.remove(box); |
| | | | |
| | } | | } |
| Line 32: |
Line 32: |
| | do { | | do { |
| | | | |
| − | queue.printStatus();
| + | queue.printStatus(); |
| − | queue.processFirstItem();
| + | queue.processFirstItem(); |
| − | | + | |
| | } while (queue.hasItems()); | | } while (queue.hasItems()); |
| | | | |
| | [[Category:Computer Programming]] | | [[Category:Computer Programming]] |