From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch03;
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.OvalSprite;
05
06 /** A sample program drawing five concentric circles. */
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 CircleTarget03
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 * Create, color, and draw five circles centered at the center of
11 * the screen. Add to the game in largest to smallest order.
12 */
13 @Override
14 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
15 OvalSprite five =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.5, 0.5);
16 five.setColor(getColor("gold"));
17 five.setLocation(0.5, 0.5);
18 addSprite(five);
19
20 OvalSprite four =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.4, 0.4);
21 four.setColor(getColor("blue"));
22 four.setLocation(0.5, 0.5);
23 addSprite(four);
24
25 OvalSprite three =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.3, 0.3);
26 three.setColor(getColor("gold"));
27 three.setLocation(0.5, 0.5);
28 addSprite(three);
29
30 OvalSprite two =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.2, 0.2);
31 two.setColor(getColor("blue"));
32 two.setLocation(0.5, 0.5);
33 addSprite(two);
34
35 OvalSprite one =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.1, 0.1);
36 one.setColor(getColor("gold"));
37 one.setLocation(0.5, 0.5);
38 addSprite(one);
39 }close braces end code blocks and must match an earlier open brace
40 }close braces end code blocks and must match an earlier open brace
41
42 //Uploaded on Mon Mar 29 21:41:05 EDT 2010
|
Download/View scg/ch03/CircleTarget03.java