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 /** Iteration demonstration */
07 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 IterateSquares
08 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
09 /**
10 * 10 randomly colored and placed rectangles on the screen
11 */
12 @Override
13 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
14 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
15 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);
16 curr.setLocation(randomDouble(), randomDouble());
17 curr.setColor(randomColor());
18 addSprite(curr);
19 }close braces end code blocks and must match an earlier open brace
20 }close braces end code blocks and must match an earlier open brace
21 }close braces end code blocks and must match an earlier open brace
22
23 //Uploaded on Mon Mar 29 21:41:06 EDT 2010
|
Download/View scg/ch08/IterateSquares.java