From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
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 * @authornull 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 IfInputExamples 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 sprite;
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 makeSprites();
21 addSprites();
22 }close braces end code blocks and must match an earlier open brace
23
24 /**makes the sprites*/
25 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
26 {open braces start code blocks and must be matched with a close brace
27 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);
28 oval.setSize(0.75);
29 oval.setLocation(0.5, 0.5);
30 }close braces end code blocks and must match an earlier open brace
31
32 /**adds the sprites to the screen*/
33 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
34 {open braces start code blocks and must be matched with a close brace
35 addSprite(oval);
36 }close braces end code blocks and must match an earlier open brace
37
38 /**handle input and game events*/
39 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
40 {open braces start code blocks and must be matched with a close brace
41 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)
42 {open braces start code blocks and must be matched with a close brace
43 oval.setLocation(getMouse2D());
44 oval.setSize(randomDouble());
45
46 String contents=this assignment operator makes the left side equal to the right side"("+adds two numbers together or concatenates Strings togethergetMouseX()+adds two numbers together or concatenates Strings together", "+adds two numbers together or concatenates Strings togethergetMouseY()+adds two numbers together or concatenates Strings together")";
47 ifif executes the next statement only if the condition in parenthesis evaluates to true(sprite!=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)
48 removeSprite(sprite);
49 sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite(contents);
50 sprite.setLocation(getMouse2D());
51 sprite.setSize(0.25);
52 sprite.setColor(newnew is used to create objects by calling the constructor Color(255, 255, 255, 128));
53 addSprite(sprite);
54 }close braces end code blocks and must match an earlier open brace
55 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'r')
56 {open braces start code blocks and must be matched with a close brace
57 oval.setLocation(getMouse2D());
58 oval.setColor(Palette.getColor("red"));
59 }close braces end code blocks and must match an earlier open brace
60 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'w')
61 {open braces start code blocks and must be matched with a close brace
62 oval.setColor(Palette.getColor("white"));
63 }close braces end code blocks and must match an earlier open brace
64 }close braces end code blocks and must match an earlier open brace
65 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/IfInputExamples.java