From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 importimport means to make the classes and/or packages available in this program fang.*;
04 importimport means to make the classes and/or packages available in this program java.awt.*;
05 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
06
07 /**
08 * All about my game.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 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 TooManyBraces extendsextends means to customize or extend the functionality of a class Game
12 {open braces start code blocks and must be matched with a close brace
13 /**an oval*/
14 privateprivate is used to restrict access to the current class only Sprite oval;
15 privateprivate is used to restrict access to the current class only Sprite oval2;
16
17 /**sets up the game*/
18 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
19 {open braces start code blocks and must be matched with a close brace
20 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
21 oval.setSize(0.75);
22 oval.setLocation(0.5, 0.5);
23
24 oval2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
25 oval2.setSize(0.75);
26 oval2.setLocation(0.75, 0.5);
27 addSprite(oval);
28 addSprite(oval2);
29 }close braces end code blocks and must match an earlier open brace
30
31 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
32 {open braces start code blocks and must be matched with a close brace
33 ifif executes the next statement only if the condition in parenthesis evaluates to true(getClick2D()!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) oval.intersects(getClick2D()))
34 {open braces start code blocks and must be matched with a close brace
35 oval.setVisible(!this is the not operator, which changes true to false and false to trueoval.isVisible());
36 }close braces end code blocks and must match an earlier open brace
37 ifif executes the next statement only if the condition in parenthesis evaluates to true(getClick2D()!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) oval2.intersects(getClick2D()))
38 {open braces start code blocks and must be matched with a close brace
39 oval2.setVisible(falsefalse is a value for the boolean type and means not true);
40 }close braces end code blocks and must match an earlier open brace
41 }close braces end code blocks and must match an earlier open brace
42 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/TooManyBraces.java