|
001 packagepackage is used to name the directory or folder a class is in matt_mitrovich_kcie_green;
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 My Name Here
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 Montyhall2 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 numclick;
014 privateprivate is used to restrict access to the current class only RectangleSprite square;
015 privateprivate is used to restrict access to the current class only RectangleSprite square2;
016 privateprivate is used to restrict access to the current class only RectangleSprite square3;
017 privateprivate is used to restrict access to the current class only RectangleSprite square4;
018 privateprivate is used to restrict access to the current class only RectangleSprite square5;
019 privateprivate is used to restrict access to the current class only RectangleSprite square6;
020 privateprivate is used to restrict access to the current class only RectangleSprite square7;
021
022 /**sets up the game*/
023 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
024 {open braces start code blocks and must be matched with a close brace
025 numclick=this assignment operator makes the left side equal to the right side0;
026
027 square7=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(.5,.5);
028 square7.setSize(.15);
029 square7.setLocation(0.80,0.50);
030 square7.setColor(Palette.getColor("RED"));
031 addSprite(square7);
032
033 square4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(.5,.5);
034 square4.setSize(.15);
035 square4.setLocation(0.20,0.50);
036 square4.setColor(Palette.getColor("White"));
037 addSprite(square4);
038
039 square5=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(.5,.5);
040 square5.setSize(.15);
041 square5.setLocation(0.50,0.50);
042 square5.setColor(Palette.getColor("White"));
043 addSprite(square5);
044
045 square6=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(.5,.5);
046 square6.setSize(.15);
047 square6.setLocation(0.80,0.50);
048 square6.setColor(Palette.getColor("White"));
049 addSprite(square6);
050
051
052
053 square=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
054 square.setSize(.25);
055 square.setLocation(0.20,0.50);
056 square.setColor(Palette.getColor("White"));
057 addSprite(square);
058
059
060 square2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
061 square2.setSize(.25);
062 square2.setLocation(0.50,0.50);
063 square2.setColor(Palette.getColor("red"));
064 addSprite(square2);
065
066
067 square3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
068 square3.setSize(.25);
069 square3.setLocation(0.80,0.50);
070 square3.setColor(Palette.getColor("blue"));
071 addSprite(square3);
072
073 }close braces end code blocks and must match an earlier open brace
074
075
076
077 /**handle input and game events*/
078 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
079 {open braces start code blocks and must be matched with a close brace
080 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 &&) square.intersects(getClick2D()))
081
082
083 {open braces start code blocks and must be matched with a close brace
084
085 square.setVisible(truetrue is the boolean value that is the opposite of false);
086 square2.setVisible(falsefalse is a value for the boolean type and means not true);
087 square3.setVisible(truetrue is the boolean value that is the opposite of false);
088 square6.setColor(Palette.getColor("LIME"));
089 square5.setColor(Palette.getColor("RED"));
090 square4.setColor(Palette.getColor("RED"));
091 square6.setLocation(.80,.50);
092
093
094 }close braces end code blocks and must match an earlier open brace
095 elseelse is what happens when the if condition is false 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 &&) square2.intersects(getClick2D()))
096
097
098 {open braces start code blocks and must be matched with a close brace
099
100 square.setVisible(truetrue is the boolean value that is the opposite of false);
101 square2.setVisible(falsefalse is a value for the boolean type and means not true);
102 square3.setVisible(truetrue is the boolean value that is the opposite of false);
103 square6.setColor(Palette.getColor("LIME"));
104 square5.setColor(Palette.getColor("RED"));
105 square4.setColor(Palette.getColor("RED"));
106 square6.setLocation(.20,.50);
107
108
109 }close braces end code blocks and must match an earlier open brace
110 elseelse is what happens when the if condition is false 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 &&) square3.intersects(getClick2D()))
111
112
113 {open braces start code blocks and must be matched with a close brace
114
115 square.setVisible(falsefalse is a value for the boolean type and means not true);
116 square2.setVisible(falsefalse is a value for the boolean type and means not true);
117 square3.setVisible(falsefalse is a value for the boolean type and means not true);
118 square6.setColor(Palette.getColor("LIME"));
119 square5.setColor(Palette.getColor("RED"));
120 square4.setColor(Palette.getColor("RED"));
121 square6.setLocation(.20,.50);
122
123 }close braces end code blocks and must match an earlier open brace
124 }close braces end code blocks and must match an earlier open brace
125 }close braces end code blocks and must match an earlier open brace
|