From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch02;
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 * Draw a basket (forfor is a looping structure for repeatedly executing a block of code "basketball") on the screen.
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 Basket
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 * Setup the sprites (and anything elseelse is what happens when the if condition is false) necessary forfor is a looping structure for repeatedly executing a block of code our game.
13 * Use the newnew is used to create objects by calling the constructor operator to construct three RectangleSprites. Each is
14 * sized and located in screens (screen is 0.0 to 1.0 from left to right
15 * across and 0.0 to 1.0 down from the top to bottom (y-axis is backward).
16 */
17 @Override
18 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
19 // width, height (in screens); location is (x, y), in screens
20 RectangleSprite rectangleBottom =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(0.25, 0.05);
21 rectangleBottom.setLocation(0.625, 0.475);
22 addSprite(rectangleBottom);
23
24 RectangleSprite rectangleBackboard =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(0.05, 0.4);
25 rectangleBackboard.setLocation(0.75, 0.3);
26 addSprite(rectangleBackboard);
27
28 RectangleSprite rectangleFrontboard =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(0.05, 0.2);
29 rectangleFrontboard.setLocation(0.50, 0.4);
30 addSprite(rectangleFrontboard);
31 }close braces end code blocks and must match an earlier open brace
32 }close braces end code blocks and must match an earlier open brace
33
34 //Uploaded on Mon Mar 29 21:40:56 EDT 2010
|
Download/View scg/ch02/Basket.java