Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860
Creating Uruk Hais - Huben's Wiki

Creating Uruk Hais

From Huben's Wiki
Jump to: navigation, search
(Created page with "Saruman did not create single monsters to attack the lands of men. Each '''class''' is a race composed of many individuals ('''instances''' or '''objects'''.) The most horrible...")
 
Line 48: Line 48:
 
# Which instance variable of each object is set directly?
 
# Which instance variable of each object is set directly?
 
# If you inserted 'one.sharedBattleCry = "Meep!";' before the declamations, what would change in the declamations?  Why?
 
# If you inserted 'one.sharedBattleCry = "Meep!";' before the declamations, what would change in the declamations?  Why?
 +
 +
== Static And Regular Methods ==
 +
 +
The '''static''' reserved word distinguishes class variables from instance variables.  It also has an important meaning for methods.  A static (class) method may not use any instance variables, though it can use class variables.  A static method may be called by its class or by one of the instances of the class with the dot notation.  But a non-static, regular method cannot be called by its class because the class has no instance variables and the method might use them.
 +
 +
# Paste the line 'UrukHai.screamTheSharedBattleCry();' at the end of main().  Look at UrukHai, and predict if it will work.  Explain why.
 +
# Paste the line 'one.screamTheSharedBattleCry();' at the end of main().  Look at UrukHai, and predict if it will work.  Explain why.
 +
# Paste the line 'UrukHai.declaim();' at the end of main().  Look at UrukHai, and predict if it will work.  Explain why.
 +
 +
== It Is Forbidden! ==
 +
 +
At last the secret meanings of the keywords '''public''' and '''private''' may be revealed to you. 
 +
* Public means that a variable or method of a class may be used by any other class.
 +
* Private means that a variable or method of a class may be used only within the same class.
 +
This is the secret of '''encapsulation''', the principle of hiding the inner workings of a class.  The public parts of a class are called the '''interface''', the private parts are concealed.

Revision as of 02:34, 1 October 2012

Personal tools
translate