From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch03;
02
03 importimport means to make the classes and/or packages available in this program fang2.core.Game;
04 importimport means to make the classes and/or packages available in this program fang2.sprites.StringSprite;
05
06 /** Demonstration of StringSprite. Msg centered horizontally. */
07 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 Strings
08 extendsextends means to customize or extend the functionality of a class Game {open braces start code blocks and must be matched with a close brace
09 /** Write the poem in four strings (6 lines).*/
10 @Override
11 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup() {open braces start code blocks and must be matched with a close brace
12 // '\n' sequence is the new line character (starts a new line)
13 StringSprite meddle =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite(
14 "Do not meddle in\nthe affairs of");
15 meddle.setLineHeight(0.10);
16 meddle.setColor(getColor("white"));
17 meddle.setLocation(0.5, 0.15);
18 addSprite(meddle);
19
20 StringSprite dragons =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("DRAGONS");
21 dragons.setLineHeight(0.15);
22 dragons.setColor(getColor("green"));
23 dragons.setLocation(0.5, 0.4);
24 addSprite(dragons);
25
26 StringSprite thou =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite(
27 "for thou art crunchy\nand go well with");
28 thou.setLineHeight(0.10);
29 thou.setColor(getColor("white"));
30 thou.setLocation(0.5, 0.65);
31 addSprite(thou);
32
33 StringSprite ketchup =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("ketchup");
34 ketchup.setLineHeight(0.20);
35 ketchup.setColor(getColor("SCG Red"));// red in the book
36 ketchup.setLocation(0.5, 0.85);
37 addSprite(ketchup);
38 }close braces end code blocks and must match an earlier open brace
39 }close braces end code blocks and must match an earlier open brace
40
41 //Uploaded on Mon Mar 29 21:40:00 EDT 2010
|
Download/View scg/ch03/Strings.java