|
001 packagepackage is used to name the directory or folder a class is in LuanNguyen;
002
003 importimport means to make the classes and/or packages available in this program wiki.Wiki;
004 importimport means to make the classes and/or packages available in this program fang.*;
005 importimport means to make the classes and/or packages available in this program java.awt.*;
006 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
007
008 /**
009 * All about my game here.
010 * @authorthis is the Javadoc tag for documenting who created the source code Lnguyen1
011 */
012 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 montyhallgame extendsextends means to customize or extend the functionality of a class GameLoop
013 {open braces start code blocks and must be matched with a close brace
014 /**an oval*/
015
016
017 privateprivate is used to restrict access to the current class only Sprite door2;
018 privateprivate is used to restrict access to the current class only Sprite door1;
019 privateprivate is used to restrict access to the current class only Sprite door3;
020 privateprivate is used to restrict access to the current class only StringSprite text;
021 privateprivate is used to restrict access to the current class only Sprite reddot;
022 privateprivate is used to restrict access to the current class only StringSprite text2;
023 privateprivate is used to restrict access to the current class only Sprite reddot2;
024 privateprivate is used to restrict access to the current class only StringSprite text3;
025 privateprivate is used to restrict access to the current class only Sprite greendot;
026 privateprivate is used to restrict access to the current class only StringSprite gametitle;
027 privateprivate is used to restrict access to the current class only StringSprite instruction;
028 privateprivate is used to restrict access to the current class only StringSprite instruction2;
029 privateprivate is used to restrict access to the current class only StringSprite instruction3;
030 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer q;
031
032
033 /**sets up the game*/
034 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
035 {open braces start code blocks and must be matched with a close brace
036 makeSprites();
037 addSprites();
038 }close braces end code blocks and must match an earlier open brace
039
040 /**makes the sprites*/
041 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
042 {open braces start code blocks and must be matched with a close brace
043 door2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
044 door2.setScale(0.25);
045 door2.setLocation(0.5, 0.5);
046
047 reddot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
048 reddot.setScale(0.1);
049 reddot.setLocation(0.5, 0.5);
050 reddot.setColor(Color.RED);
051
052 door1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
053 door1.setScale(0.25);
054 door1.setLocation(0.2, 0.5);
055
056 door3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
057 door3.setScale(0.25);
058 door3.setLocation(0.8, 0.5);
059
060 reddot2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
061 reddot2.setScale(0.1);
062 reddot2.setLocation(0.8, 0.5);
063 reddot2.setColor(Color.RED);
064
065 text=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("2");
066 text.setScale(0.1);
067 text.setColor(Color.RED);
068 text.setLocation(0.5, 0.5);
069
070 greendot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
071 greendot.setScale(0.1);
072 greendot.setColor(Color.GREEN);
073 greendot.setLocation(0.2, 0.5);
074
075 text2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("1");
076 text2.setScale(0.1);
077 text2.setColor(Color.RED);
078 text2.setLocation(0.2, 0.5);
079
080 text3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("3");
081 text3.setScale(0.1);
082 text3.setColor(Color.RED);
083 text3.setLocation(0.8, 0.5);
084
085 gametitle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite ("Let's Make A Deal");
086 gametitle.setScale(0.5);
087 gametitle.setColor(Color.BLUE);
088 gametitle.setLocation(0.5, 0.1);
089
090 instruction=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Inside one of these cases is a $1000 Prize");
091 instruction.setScale(0.8);
092 instruction.setColor(Color.RED);
093 instruction.setLocation(0.5, 0.15);
094
095 instruction2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Inside the others case are either $0.1 or $1");
096 instruction2.setScale(0.8);
097 instruction2.setColor(Color.YELLOW);
098 instruction2.setLocation(0.5, 0.2);
099
100 instruction3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Click on the case to open the $1000 case");
101 instruction3.setScale(0.8);
102 instruction3.setColor(Color.GREEN);
103 instruction3.setLocation(0.5, 0.25);
104
105 intint is the type for whole numbers and it is short for integer q=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
106
107 }close braces end code blocks and must match an earlier open brace
108
109 /**adds the sprites to the screen*/
110 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
111 {open braces start code blocks and must be matched with a close brace
112 canvas.addSprite(reddot);
113 canvas.addSprite(reddot2);
114 canvas.addSprite(greendot);
115 canvas.addSprite(door2);
116 canvas.addSprite(door1);
117 canvas.addSprite(door3);
118 canvas.addSprite(text);
119 canvas.addSprite(text2);
120 canvas.addSprite(text3);
121 canvas.addSprite(gametitle);
122 canvas.addSprite(instruction);
123 canvas.addSprite(instruction2);
124 canvas.addSprite(instruction3);
125
126 }close braces end code blocks and must match an earlier open brace
127
128 /**handle input and game events*/
129 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)
130 {open braces start code blocks and must be matched with a close brace
131 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
132 ifif executes the next statement only if the condition in parenthesis evaluates to true(click!=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)
133 {open braces start code blocks and must be matched with a close brace
134 ifif executes the next statement only if the condition in parenthesis evaluates to true(door2.intersects(click))
135 {open braces start code blocks and must be matched with a close brace
136 canvas.removeSprite(door3);
137 }close braces end code blocks and must match an earlier open brace
138 ifif executes the next statement only if the condition in parenthesis evaluates to true(door1.intersects(click))
139 {open braces start code blocks and must be matched with a close brace
140 intint is the type for whole numbers and it is short for integer q=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
141 ifif executes the next statement only if the condition in parenthesis evaluates to true(q==this is the comparison operator which evaluates to true if both sides are the same0)
142 {open braces start code blocks and must be matched with a close brace
143 canvas.removeSprite(door2);
144 }close braces end code blocks and must match an earlier open brace
145 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(q==this is the comparison operator which evaluates to true if both sides are the same1)
146 {open braces start code blocks and must be matched with a close brace
147 canvas.removeSprite(door3);
148 }close braces end code blocks and must match an earlier open brace
149 }close braces end code blocks and must match an earlier open brace
150 ifif executes the next statement only if the condition in parenthesis evaluates to true(door3.intersects(click))
151 {open braces start code blocks and must be matched with a close brace
152 canvas.removeSprite(door2);
153
154 }close braces end code blocks and must match an earlier open brace
155
156 }close braces end code blocks and must match an earlier open brace
157
158 }close braces end code blocks and must match an earlier open brace
159
160
161
162
163 }close braces end code blocks and must match an earlier open brace
|