From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch09;
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.StringSprite;
05
06 /**
07 * The "game" is really just a level of the mainThe main method is the place where applications begin executing. game. It is
08 * constructed to display a message on how well the player did (it is
09 * initialized with the player's score) and then the setup creates a
10 * centered end-of-game message.
11 */
12 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 EndOfGame
13 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
14 /** the score provided to the constructor */
15 privateprivate is used to restrict access to the current class only finalfinal means not changeable (often used for constants) intint is the type for whole numbers and it is short for integer initialScore;
16
17 /**
18 * Construct a newnew is used to create objects by calling the constructor EndOfGame level. Requires the score to display forfor is a looping structure for repeatedly executing a block of code
19 * the player.
20 *
21 * @paramthis is the Javadoc tag for documenting the purpose of parameters initialScore the player's score
22 */
23 publicpublic is used to indicate unrestricted access (any other class can have access) EndOfGame(intint is the type for whole numbers and it is short for integer initialScore) {open braces start code blocks and must be matched with a close brace
24 thisthis means the current object (the implicit parameter).initialScore =this assignment operator makes the left side equal to the right side initialScore;
25 }close braces end code blocks and must match an earlier open brace
26
27 /**
28 * Setup the display information on the screen.
29 */
30 @Override
31 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
32 setScore(initialScore);
33 StringSprite announcement =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite();
34 announcement.setText("GAME OVER\nFinal Score: " +adds two numbers together or concatenates Strings together getScore());
35 announcement.setScale(1.0);
36 announcement.setLocation(0.5, 0.5);
37 addSprite(announcement);
38 }close braces end code blocks and must match an earlier open brace
39 }close braces end code blocks and must match an earlier open brace
40
41 //Uploaded on Mon Mar 29 21:39:39 EDT 2010
|
Download/View scg/ch09/EndOfGame.java