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.OvalSprite;
05
06 /** Draws two eyes and uses two overlapping ovals to draw a mouth. */
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 Ovals
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 /**
10 * Draw four ovals; one in background color
11 */
12 @Override
13 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
14 OvalSprite white =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.7, 0.2);
15 white.setColor(getColor("white"));
16 white.setLocation(0.5, 0.5);
17 addSprite(white);
18
19 OvalSprite black =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.7, 0.2);
20 black.setColor(getColor("black"));
21 black.setLocation(0.5, 0.4);
22 addSprite(black);
23
24 OvalSprite left =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.2, 0.2);
25 left.setColor(getColor("white"));
26 left.setLocation(0.25, 0.25);
27 addSprite(left);
28
29 OvalSprite right =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.2, 0.2);
30 right.setColor(getColor("white"));
31 right.setLocation(0.75, 0.25);
32 addSprite(right);
33 }close braces end code blocks and must match an earlier open brace
34 }close braces end code blocks and must match an earlier open brace
35
36 //Uploaded on Mon Mar 29 21:40:16 EDT 2010
|
Download/View scg/ch03/Ovals.java