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 wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program fang.*;
05 importimport means to make the classes and/or packages available in this program java.awt.*;
06 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
07
08 /**
09 * All about my game here.
10 * @authornull Jam Jenkins
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 CompositeExample extendsextends means to customize or extend the functionality of a class GameLoop
13 {open braces start code blocks and must be matched with a close brace
14 /**an oval*/
15 privateprivate is used to restrict access to the current class only CompositeSprite oval;
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 startGame()
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 CompositeSprite();
28 PolygonSprite pentagon=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(5);
29 pentagon.setScale(0.25);
30 pentagon.setLocation(0.05, 0);
31 oval.addShape(pentagon.getShape(), Color.RED);
32 OvalSprite circle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
33 circle.setScale(0.25);
34 circle.setLocation(0.5, 0);
35 oval.addShape(circle.getShape(), Color.YELLOW);
36 pentagon.setLocation(0.95, 0);
37 oval.addShape(pentagon.getShape(), Color.BLUE);
38 oval.setScale(0.75);
39 oval.setLocation(0.5, 0.5);
40 }close braces end code blocks and must match an earlier open brace
41
42 /**adds the sprites to the screen*/
43 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
44 {open braces start code blocks and must be matched with a close brace
45 canvas.addSprite(oval);
46 }close braces end code blocks and must match an earlier open brace
47
48 /**handle input and game events*/
49 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timePassed)
50 {open braces start code blocks and must be matched with a close brace
51 oval.setLocation(getPlayer().getMouse().getLocation());
52 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getMouse().getClickLocation()!=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)
53 {open braces start code blocks and must be matched with a close brace
54 oval.setScale(random.nextDouble());
55 }close braces end code blocks and must match an earlier open brace
56 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same'r')
57 {open braces start code blocks and must be matched with a close brace
58 oval.setColor(Color.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(getPlayer().getKeyboard().getLastKey()==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(Color.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
|
Compiler Errors:
----------
1. ERROR in jam/CompositeExample.java (at line 31)
oval.addShape(pentagon.getShape(), Color.RED);
^^^^^^^^
The method addShape(Shape, Color) is undefined for the type CompositeSprite
----------
2. ERROR in jam/CompositeExample.java (at line 35)
oval.addShape(circle.getShape(), Color.YELLOW);
^^^^^^^^
The method addShape(Shape, Color) is undefined for the type CompositeSprite
----------
3 problems (3 errors)
Download/View jam/CompositeExample.java