From FANG
|
001 packagepackage is used to name the directory or folder a class is in scg.ch10;
002
003 importimport means to make the classes and/or packages available in this program java.awt.Color;
004
005 importimport means to make the classes and/or packages available in this program fang2.core.Game;
006 importimport means to make the classes and/or packages available in this program fang2.sprites.StringSprite;
007
008 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 LetterSprite
009 extendsextends means to customize or extend the functionality of a class StringSprite {open braces start code blocks and must be matched with a close brace
010 /** defaultdefault is what is executed when no cases are matched color values; can be overridden in constructor */
011 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) Color DEFAULT_READY_COLOR =this assignment operator makes the left side equal to the right side Game.getColor("SCG Red");
012 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) Color DEFAULT_USED_COLOR =this assignment operator makes the left side equal to the right side Game.getColor("Gray");
013
014 /** the letter thisthis means the current object (the implicit parameter) sprite displays/represents */
015 privateprivate is used to restrict access to the current class only finalfinal means not changeable (often used for constants) charchar is the type for a single letter or symbol and it is short for character letter;
016
017 /** the colors used by thisthis means the current object (the implicit parameter) sprite to indicate its two states */
018 privateprivate is used to restrict access to the current class only Color readyColor;
019
020 /** is the letter in the used (or ready) state */
021 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false used;
022
023 privateprivate is used to restrict access to the current class only Color usedColor;
024
025 /**
026 * Construct a newnew is used to create objects by calling the constructor LetterSprite. Uses the defaultdefault is what is executed when no cases are matched colors
027 */
028 publicpublic is used to indicate unrestricted access (any other class can have access) LetterSprite(charchar is the type for a single letter or symbol and it is short for character letter) {open braces start code blocks and must be matched with a close brace
029 thisthis means the current object (the implicit parameter)(letter, DEFAULT_READY_COLOR, DEFAULT_USED_COLOR);
030 }close braces end code blocks and must match an earlier open brace
031
032 /**
033 * Construct a newnew is used to create objects by calling the constructor LetterSprite with the given letter and colors.
034 */
035 publicpublic is used to indicate unrestricted access (any other class can have access) LetterSprite(charchar is the type for a single letter or symbol and it is short for character letter, Color readyColor, Color usedColor) {open braces start code blocks and must be matched with a close brace
036 super();
037 setMonospaced(truetrue is the boolean value that is the opposite of false);
038 thisthis means the current object (the implicit parameter).letter =this assignment operator makes the left side equal to the right side letter;
039 setReadyColor(readyColor);
040 setUsedColor(usedColor);
041 setText(Character.toString(thisthis means the current object (the implicit parameter).letter));
042 startReady();
043 }close braces end code blocks and must match an earlier open brace
044
045 /**
046 * Get the letter stored in thisthis means the current object (the implicit parameter) letter sprite
047 *
048 * @returnnull the letter shown by thisthis means the current object (the implicit parameter) letter sprite
049 */
050 publicpublic is used to indicate unrestricted access (any other class can have access) charchar is the type for a single letter or symbol and it is short for character getLetter() {open braces start code blocks and must be matched with a close brace
051 returnreturn means to provide the result of the method and/or cease execution of the method immediately letter;
052 }close braces end code blocks and must match an earlier open brace
053
054 /**
055 * Return the ready color. Color used when the sprite is in ready
056 * state.
057 *
058 * @returnnull color of sprite in ready state
059 */
060 publicpublic is used to indicate unrestricted access (any other class can have access) Color getReadyColor() {open braces start code blocks and must be matched with a close brace
061 returnreturn means to provide the result of the method and/or cease execution of the method immediately readyColor;
062 }close braces end code blocks and must match an earlier open brace
063
064 /**
065 * Return the used color. Color used when the sprite is in used
066 * (selected) state.
067 *
068 * @returnnull color of sprite in used state
069 */
070 publicpublic is used to indicate unrestricted access (any other class can have access) Color getUsedColor() {open braces start code blocks and must be matched with a close brace
071 returnreturn means to provide the result of the method and/or cease execution of the method immediately usedColor;
072 }close braces end code blocks and must match an earlier open brace
073
074 /**
075 * Is the sprite in the ready state?
076 *
077 * @returnnull truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true ready (to be selected); falsefalse is a value for the boolean type and means not true otherwise
078 */
079 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isReady() {open braces start code blocks and must be matched with a close brace
080 returnreturn means to provide the result of the method and/or cease execution of the method immediately !this is the not operator, which changes true to false and false to trueused;
081 }close braces end code blocks and must match an earlier open brace
082
083 /**
084 * Is the sprite in the used (already selected) state?
085 *
086 * @returnnull truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true used (no longer selectable); falsefalse is a value for the boolean type and means not true otherwise
087 */
088 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isUsed() {open braces start code blocks and must be matched with a close brace
089 returnreturn means to provide the result of the method and/or cease execution of the method immediately used;
090 }close braces end code blocks and must match an earlier open brace
091
092 /**
093 * Set the color to to use when in the ready state
094 *
095 * @paramthis is the Javadoc tag for documenting the purpose of parameters readyColor the newnew is used to create objects by calling the constructor ready state display color
096 */
097 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setReadyColor(Color readyColor) {open braces start code blocks and must be matched with a close brace
098 thisthis means the current object (the implicit parameter).readyColor =this assignment operator makes the left side equal to the right side readyColor;
099 }close braces end code blocks and must match an earlier open brace
100
101 /**
102 * Set the color to use when in the used state.
103 *
104 * @paramthis is the Javadoc tag for documenting the purpose of parameters usedColor the newnew is used to create objects by calling the constructor used state display color
105 */
106 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setUsedColor(Color usedColor) {open braces start code blocks and must be matched with a close brace
107 thisthis means the current object (the implicit parameter).usedColor =this assignment operator makes the left side equal to the right side usedColor;
108 }close braces end code blocks and must match an earlier open brace
109
110 /**
111 * Unconditionally go into the ready state.
112 */
113 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startReady() {open braces start code blocks and must be matched with a close brace
114 setColor(getReadyColor());
115 used =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
116 }close braces end code blocks and must match an earlier open brace
117
118 /**
119 * Unconditionally go into the used state.
120 */
121 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startUsed() {open braces start code blocks and must be matched with a close brace
122 setColor(getUsedColor());
123 used =this assignment operator makes the left side equal to the right side truetrue is the boolean value that is the opposite of false;
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
126
127 //Uploaded on Mon Mar 29 21:41:57 EDT 2010
|
Download/View scg/ch10/LetterSprite.java