From ggc
|
001 packagepackage is used to name the directory or folder a class is in intro;
002
003 importimport means to make the classes and/or packages available in this program fang.*;
004 importimport means to make the classes and/or packages available in this program java.awt.*;
005 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
006
007 /**
008 * All about my game.
009 * @authorthis is the Javadoc tag for documenting who created the source code Dr. Jam Jenkins
010 */
011 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 DisappearingAct extendsextends means to customize or extend the functionality of a class Game
012 {open braces start code blocks and must be matched with a close brace
013 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer numClicks;
014 privateprivate is used to restrict access to the current class only OvalSprite oval;
015 privateprivate is used to restrict access to the current class only StringSprite alert;
016
017 /**sets up the game*/
018 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
019 {open braces start code blocks and must be matched with a close brace
020 numClicks=this assignment operator makes the left side equal to the right side0;
021 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(0.25, 0.25);
022 oval.setLocation(0.5, 0.5);
023 addSprite(oval);
024
025 alert=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Alert");
026 alert.setWidth(0.5);
027 alert.setLocation(0.5, 0.8);
028 addSprite(alert);
029 alert.setVisible(falsefalse is a value for the boolean type and means not true);
030 }close braces end code blocks and must match an earlier open brace
031
032 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeGreen()
033 {open braces start code blocks and must be matched with a close brace
034 oval.setVisible(truetrue is the boolean value that is the opposite of false);
035 oval.setLocation(0.5, 0.75);
036 oval.setColor(getColor("green"));
037 }close braces end code blocks and must match an earlier open brace
038 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeYellow()
039 {open braces start code blocks and must be matched with a close brace
040 oval.setVisible(truetrue is the boolean value that is the opposite of false);
041 oval.setLocation(0.5, 0.5);
042 oval.setColor(getColor("yellow"));
043 }close braces end code blocks and must match an earlier open brace
044 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeRed()
045 {open braces start code blocks and must be matched with a close brace
046 oval.setVisible(truetrue is the boolean value that is the opposite of false);
047 oval.setLocation(0.5, 0.25);
048 oval.setColor(getColor("red"));
049 }close braces end code blocks and must match an earlier open brace
050
051 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeInvisible()
052 {open braces start code blocks and must be matched with a close brace
053 oval.setVisible(falsefalse is a value for the boolean type and means not true);
054 numClicks=this assignment operator makes the left side equal to the right side-1;
055 }close braces end code blocks and must match an earlier open brace
056
057 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value placeAndColor(doubledouble is the type for numbers that can contain decimal fractions x, doubledouble is the type for numbers that can contain decimal fractions y, Color color)
058 {open braces start code blocks and must be matched with a close brace
059 oval.setVisible(truetrue is the boolean value that is the opposite of false);
060 oval.setLocation(x, y);
061 oval.setColor(color);
062 }close braces end code blocks and must match an earlier open brace
063
064 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isYellow()
065 {open braces start code blocks and must be matched with a close brace
066 ifif executes the next statement only if the condition in parenthesis evaluates to true(oval.getColor().equals(getColor("yellow")))
067 {open braces start code blocks and must be matched with a close brace
068 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
069 }close braces end code blocks and must match an earlier open brace
070 elseelse is what happens when the if condition is false
071 {open braces start code blocks and must be matched with a close brace
072 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
073 }close braces end code blocks and must match an earlier open brace
074 }close braces end code blocks and must match an earlier open brace
075
076 /**handle input and game events*/
077 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
078 {open braces start code blocks and must be matched with a close brace
079 ifif executes the next statement only if the condition in parenthesis evaluates to true(isYellow()==this is the comparison operator which evaluates to true if both sides are the sametruetrue is the boolean value that is the opposite of false)
080 {open braces start code blocks and must be matched with a close brace
081 alert.setVisible(truetrue is the boolean value that is the opposite of false);
082 }close braces end code blocks and must match an earlier open brace
083 elseelse is what happens when the if condition is false
084 {open braces start code blocks and must be matched with a close brace
085 alert.setVisible(falsefalse is a value for the boolean type and means not true);
086 }close braces end code blocks and must match an earlier open brace
087 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 &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 &&) oval.intersects(getClick2D()))
088 {open braces start code blocks and must be matched with a close brace
089 numClicks++this is the increment operator, which increases the variable by 1;
090 }close braces end code blocks and must match an earlier open brace
091 ifif executes the next statement only if the condition in parenthesis evaluates to true(numClicks==this is the comparison operator which evaluates to true if both sides are the same0)
092 {open braces start code blocks and must be matched with a close brace
093 //makeGreen();
094 placeAndColor(0.5, 0.75, getColor("green"));
095 }close braces end code blocks and must match an earlier open brace
096 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(numClicks==this is the comparison operator which evaluates to true if both sides are the same1)
097 {open braces start code blocks and must be matched with a close brace
098 //makeYellow();
099 placeAndColor(0.5, 0.5, getColor("yellow"));
100 }close braces end code blocks and must match an earlier open brace
101 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(numClicks==this is the comparison operator which evaluates to true if both sides are the same2)
102 {open braces start code blocks and must be matched with a close brace
103 //makeRed();
104 placeAndColor(0.5, 0.25, getColor("red"));
105 numClicks=this assignment operator makes the left side equal to the right side-1;
106 }close braces end code blocks and must match an earlier open brace
107 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(numClicks==this is the comparison operator which evaluates to true if both sides are the same3)
108 {open braces start code blocks and must be matched with a close brace
109 makeInvisible();
110 }close braces end code blocks and must match an earlier open brace
111 }close braces end code blocks and must match an earlier open brace
112 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/DisappearingAct.java