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 * @authorthis is the Javadoc tag for documenting who created the source code 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 ReturnTypeExample 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 /**sets up the game*/
15 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
16 {open braces start code blocks and must be matched with a close brace
17 canvas.addSprite(makeRandomSprite());
18 canvas.addSprite(makeRandomSprite());
19 canvas.addSprite(makeRandomSprite());
20 canvas.addSprite(makeRandomSprite());
21 canvas.addSprite(makeRandomSprite());
22 canvas.addSprite(makeRandomSprite());
23 canvas.addSprite(makeRandomSprite());
24 canvas.addSprite(makeRandomSprite());
25 canvas.addSprite(makeRandomSprite());
26 }close braces end code blocks and must match an earlier open brace
27
28 privateprivate is used to restrict access to the current class only Sprite makeRandomSprite()
29 {open braces start code blocks and must be matched with a close brace
30 Sprite x=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(random.nextInt(6)+adds two numbers together or concatenates Strings together3);
31 x.setScale(random.nextDouble());
32 x.setLocation(random.nextDouble(), random.nextDouble());
33 x.setColor(getRandomColor());
34 returnreturn means to provide the result of the method and/or cease execution of the method immediately x;
35 }close braces end code blocks and must match an earlier open brace
36
37 privateprivate is used to restrict access to the current class only Color getRandomColor()
38 {open braces start code blocks and must be matched with a close brace
39 Color color=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
40 returnreturn means to provide the result of the method and/or cease execution of the method immediately color;
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 Jam/ReturnTypeExample.java