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 GraphicUserInterface 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 Model model;
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 model=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Model();
21 makeSprites();
22 addSprites();
23 }close braces end code blocks and must match an earlier open brace
24
25 /**makes the sprites*/
26 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
27 {open braces start code blocks and must be matched with a close brace
28 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);
29 String colorName=this assignment operator makes the left side equal to the right sidemodel.getColor();
30 oval.setColor(getColor(colorName));
31 oval.setSize(0.75);
32 oval.setLocation(0.5, 0.5);
33 }close braces end code blocks and must match an earlier open brace
34
35 /**adds the sprites to the screen*/
36 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
37 {open braces start code blocks and must be matched with a close brace
38 addSprite(oval);
39 }close braces end code blocks and must match an earlier open brace
40
41 /**handle input and game events*/
42 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
43 {open braces start code blocks and must be matched with a close brace
44 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)
45 {open braces start code blocks and must be matched with a close brace
46 model.toggle();
47 }close braces end code blocks and must match an earlier open brace
48 String colorName=this assignment operator makes the left side equal to the right sidemodel.getColor();
49 oval.setColor(getColor(colorName));
50 }close braces end code blocks and must match an earlier open brace
51 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/GraphicUserInterface.java