From ggc
|
01 packagepackage is used to name the directory or folder a class is in arcade;
02
03 importimport means to make the classes and/or packages available in this program fang.GameLevel;
04
05 /**
06 * This classclass is a group of fields and methods used for making objects represents a single game that could
07 * be played as part of an overall arcade. Make
08 * your classclass is a group of fields and methods used for making objects extend ArcadeLevel instead of GameLoop,
09 * and change the name of startGame to startLevel
10 * and your game can be included in the arcade by
11 * adding your game to ArcadeGame. ArcadeLevels follow
12 * a heirarchical structure.
13 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
14 *
15 */
16 publicpublic is used to indicate unrestricted access (any other class can have access) abstractAbstract means there is implementation missing. classclass is a group of fields and methods used for making objects ArcadeLevel
17 extendsextends means to customize or extend the functionality of a class GameLevel
18 implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparable
19 {open braces start code blocks and must be matched with a close brace
20 /**the level that the game should go to
21 * after finishing thisthis means the current object (the implicit parameter) level.*/
22 privateprivate is used to restrict access to the current class only ArcadeLevel parent;
23
24 /**
25 * sets the level that the game should
26 * go to after thisthis means the current object (the implicit parameter) level finishes.
27 * Most classes should not need to
28 * call thisthis means the current object (the implicit parameter) method - it is primarily
29 * called from the ArcadeGame.
30 * @paramthis is the Javadoc tag for documenting the purpose of parameters p the next level to go to
31 */
32 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setParent(ArcadeLevel p)
33 {open braces start code blocks and must be matched with a close brace
34 parent=this assignment operator makes the left side equal to the right sidep;
35 }close braces end code blocks and must match an earlier open brace
36
37 /**
38 * gets which level the game should go
39 * to after thisthis means the current object (the implicit parameter) one finishes
40 * @returnnull the next level after the current
41 * level ends
42 */
43 publicpublic is used to indicate unrestricted access (any other class can have access) ArcadeLevel getParent()
44 {open braces start code blocks and must be matched with a close brace
45 returnreturn means to provide the result of the method and/or cease execution of the method immediately parent;
46 }close braces end code blocks and must match an earlier open brace
47
48 @Override
49 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value finishLevel()
50 {open braces start code blocks and must be matched with a close brace
51 ifif executes the next statement only if the condition in parenthesis evaluates to true(parent!=this is the not equals operator which evaluates to true if both sides are differentthisthis means the current object (the implicit parameter))
52 setNextLevel(parent);
53 super.finishLevel();
54 }close braces end code blocks and must match an earlier open brace
55
56 /**
57 * thisthis means the current object (the implicit parameter) method simply returns the fully
58 * qualified name of the classclass is a group of fields and methods used for making objects. Most
59 * games should override thisthis means the current object (the implicit parameter) method and
60 * provide their own unique name.
61 * @returnnull the name of the game used
62 * in the display
63 */
64 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
65 {open braces start code blocks and must be matched with a close brace
66 System.out.println("returning "+adds two numbers together or concatenates Strings togethergetClass().getCanonicalName());
67 returnreturn means to provide the result of the method and/or cease execution of the method immediately getClass().getCanonicalName();
68 }close braces end code blocks and must match an earlier open brace
69
70
71 @Override
72 /**
73 * classes extending ArcadeLevel must implement
74 * thisthis means the current object (the implicit parameter) method.
75 */
76 publicpublic is used to indicate unrestricted access (any other class can have access) abstractAbstract means there is implementation missing. voidvoid means the method does not return a value advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timePassed);
77
78 @Override
79 /**
80 * classes extending ArcadeLevel must implement
81 * thisthis means the current object (the implicit parameter) method.
82 */
83 publicpublic is used to indicate unrestricted access (any other class can have access) abstractAbstract means there is implementation missing. voidvoid means the method does not return a value startLevel();
84
85 /**
86 * calls the compareTo method on the game names.
87 * This is used so that games can be arranged in
88 * alphabetical order.
89 */
90 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer compareTo(Object o)
91 {open braces start code blocks and must be matched with a close brace
92 System.out.println("o is "+adds two numbers together or concatenates Strings togethero);
93 System.out.println("toString is "+adds two numbers together or concatenates Strings togethertoString());
94 returnreturn means to provide the result of the method and/or cease execution of the method immediately toString().compareTo(o.toString());
95 }close braces end code blocks and must match an earlier open brace
96 }close braces end code blocks and must match an earlier open brace
97
|
Download/View arcade/ArcadeLevel.java