|
001 packagepackage is used to name the directory or folder a class is in jam;
002
003
004
005 importimport means to make the classes and/or packages available in this program fang.*;
006
007 importimport means to make the classes and/or packages available in this program java.util.ArrayList;
008 importimport means to make the classes and/or packages available in this program java.util.HashMap;
009 importimport means to make the classes and/or packages available in this program java.util.Map;
010
011
012 /**
013 * This program shows all of the sprite shapes.
014 *
015 * @authorthis is the Javadoc tag for documenting who created the source code Robert C. Duvall
016 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
017 */
018 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 SpriteMakingHelp
019 extendsextends means to customize or extend the functionality of a class Game
020 {open braces start code blocks and must be matched with a close brace
021 /**the color swatches*/
022 privateprivate is used to restrict access to the current class only Map<Sprite, String> sprites;
023
024 privateprivate is used to restrict access to the current class only StringSprite code;
025 /**makes and adds the sprites*/
026 @Override
027 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
028 {open braces start code blocks and must be matched with a close brace
029 code=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("");
030 code.setLineHeight(0.05);
031 code.leftJustify();
032 code.bottomJustify();
033 code.setLocation(0.05, 0.95);
034 addSprite(code);
035 sprites =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor HashMap<Sprite, String>();
036 sprites.put(newnew is used to create objects by calling the constructor ArcSprite(1, 1, 45, 270),
037 "ArcSprite sample;\n"+adds two numbers together or concatenates Strings together
038 "sample=new ArcSprite(1, 1, 45, 270);");
039 sprites.put(newnew is used to create objects by calling the constructor PieSprite(1, 1, 45, 270),
040 "PieSprite sample;\n" +adds two numbers together or concatenates Strings together
041 "sample=new PieSprite(1, 1, 45, 270);");
042 sprites.put(newnew is used to create objects by calling the constructor OvalSprite(1, 1),
043 "OvalSprite sample;\n" +adds two numbers together or concatenates Strings together
044 "sample=new OvalSprite(1, 1);");
045 sprites.put(newnew is used to create objects by calling the constructor RectangleSprite(1, 1),
046 "RectangleSprite sample;\n" +adds two numbers together or concatenates Strings together
047 "sample=new RectangleSprite(1, 1);");
048 sprites.put(newnew is used to create objects by calling the constructor LineSprite(0, 0, 1, 1),
049 "LineSprite sample;\n" +adds two numbers together or concatenates Strings together
050 "sample=new LineSprite(0, 0, 1, 1);");
051 sprites.put(newnew is used to create objects by calling the constructor PolygonSprite(6),
052 "PolygonSprite sample;\n" +adds two numbers together or concatenates Strings together
053 "sample=new PolygonSprite(6);");
054 sprites.put(newnew is used to create objects by calling the constructor ImageSprite("JavaWIDE.png"),
055 "ImageSprite sample;\n" +adds two numbers together or concatenates Strings together
056 "sample=new ImageSprite(\"JavaWIDE.png\");");
057 sprites.put(newnew is used to create objects by calling the constructor StringSprite("Text"),
058 "StringSprite sample;\n" +adds two numbers together or concatenates Strings together
059 "sample=new StringSprite(\"Text\");");
060 sprites.put(newnew is used to create objects by calling the constructor ButtonSprite("Push"),
061 "ButtonSprite sample;\n" +adds two numbers together or concatenates Strings together
062 "sample=new ButtonSprite(\"Push\");");
063
064 intint is the type for whole numbers and it is short for integer index =this assignment operator makes the left side equal to the right side 0;
065 Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays keys=this assignment operator makes the left side equal to the right sidesprites.keySet().toArray(newnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
066 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer r =this assignment operator makes the left side equal to the right side 0; r < 2; r++this is the increment operator, which increases the variable by 1)
067 {open braces start code blocks and must be matched with a close brace
068 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer c =this assignment operator makes the left side equal to the right side 0; c < 5; c++this is the increment operator, which increases the variable by 1)
069 {open braces start code blocks and must be matched with a close brace
070 ifif executes the next statement only if the condition in parenthesis evaluates to true(r==this is the comparison operator which evaluates to true if both sides are the same1 &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 &&) c==this is the comparison operator which evaluates to true if both sides are the same4) breakbreak terminates the loop immediately;
071 Sprite s =this assignment operator makes the left side equal to the right side keys[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
072 String help=this assignment operator makes the left side equal to the right sidesprites.get(s);
073 s.setSize(0.15);
074 s.setLocation((c +adds two numbers together or concatenates Strings together 0.5)/5,
075 (r +adds two numbers together or concatenates Strings together 0.5)/5);
076 help+=this increases the variable on the left by the value on the right"\nsample.setSize("+adds two numbers together or concatenates Strings together
077 s.getScale()+adds two numbers together or concatenates Strings together");";
078 help+=this increases the variable on the left by the value on the right"\nsample.setLocation("+adds two numbers together or concatenates Strings together
079 s.getLocation().x+adds two numbers together or concatenates Strings together", "+adds two numbers together or concatenates Strings together
080 s.getLocation().y+adds two numbers together or concatenates Strings together");";
081 help+=this increases the variable on the left by the value on the right"\naddSprite(sample);";
082 sprites.put(s, help);
083 index++this is the increment operator, which increases the variable by 1;
084 canvas.addSprite(s);
085 code.setText(sprites.get(s));
086 }close braces end code blocks and must match an earlier open brace
087 }close braces end code blocks and must match an earlier open brace
088 }close braces end code blocks and must match an earlier open brace
089
090 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
091 {open braces start code blocks and must be matched with a close brace
092 forfor is a looping structure for repeatedly executing a block of code(Sprite key: sprites.keySet())
093 {open braces start code blocks and must be matched with a close brace
094 ifif executes the next statement only if the condition in parenthesis evaluates to true(key.getShape().getBounds2D().contains(getMouse2D()))
095 {open braces start code blocks and must be matched with a close brace
096 code.setText(sprites.get(key));
097 code.setWidth(0.9);
098 }close braces end code blocks and must match an earlier open brace
099 }close braces end code blocks and must match an earlier open brace
100 }close braces end code blocks and must match an earlier open brace
101
102 /**runs thisthis means the current object (the implicit parameter) example as an application
103 * @paramthis is the Javadoc tag for documenting the purpose of parameters args not used
104 */
105 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
106 {open braces start code blocks and must be matched with a close brace
107 newnew is used to create objects by calling the constructor SpriteMakingHelp().runAsApplication();
108 //app.pauseToggle();
109 }close braces end code blocks and must match an earlier open brace
110 }close braces end code blocks and must match an earlier open brace
|