From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch08;
02
03 importimport means to make the classes and/or packages available in this program fang2.core.Game;
04 importimport means to make the classes and/or packages available in this program fang2.sprites.RectangleSprite;
05
06 /**
07 * Iteration demonstration
08 */
09 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects IteratedRectangleSprites
10 extendsextends means to customize or extend the functionality of a class Game {open braces start code blocks and must be matched with a close brace
11 /**
12 * 10 randomly colored and placed rectangles on the screen
13 */
14 @Override
15 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup() {open braces start code blocks and must be matched with a close brace
16 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer i =this assignment operator makes the left side equal to the right side 0; i !=this is the not equals operator which evaluates to true if both sides are different 10; ++this is the increment operator, which increases the variable by 1i) {open braces start code blocks and must be matched with a close brace
17 RectangleSprite curr =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(0.1, 0.1);
18 curr.setLocation(randomDouble(), randomDouble());
19 curr.setColor(randomColor());
20 addSprite(curr);
21 }close braces end code blocks and must match an earlier open brace
22 }close braces end code blocks and must match an earlier open brace
23 }close braces end code blocks and must match an earlier open brace
24
25 //Uploaded on Mon Mar 29 21:39:54 EDT 2010
|
Download/View scg/ch08/IteratedRectangleSprites.java