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(): 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(): 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(): 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
Commanding The Demons - Huben's Wiki

Commanding The Demons

From Huben's Wiki
Jump to: navigation, search
(Created page with "Today we will study the basic principles by which we command demons, and make them dance to our whims! ==The Anatomy Of Demon Commands== Consider this, our SimpleDemon from befo...")
 
 
Line 1: Line 1:
 +
[[Image:The-shadows-of-goetia.gif]]
 +
 
Today we will study the basic principles by which we command demons, and make them dance to our whims!
 
Today we will study the basic principles by which we command demons, and make them dance to our whims!
  
==The Anatomy Of Demon Commands==
+
==(A) The Anatomy Of Demon Commands==
 
Consider this, our SimpleDemon from before.
 
Consider this, our SimpleDemon from before.
  
 
<pre>
 
<pre>
 
1  public class SimpleDemon                          // class name
 
1  public class SimpleDemon                          // class name
2  {                                                                 // start of class body
+
2  {                                                 // start of class body
 
3
 
3
4    static public void main(String[] args)         // method signature
+
4    static public void main(String[] args)         // method signature
5    {                                                               // start of method body
+
5    {                                               // start of method body
6      System.out.println("Hello world!");         // statement in method body
+
6      System.out.println("Hello world!");           // statement in method body
7    }                                                               // end of method body
+
7    }                                               // end of method body
 
8
 
8
9  }                                                                 // end of class body
+
9  }                                                 // end of class body
 
</pre>
 
</pre>
  
Line 22: Line 24:
 
*** What the demon will give you when you invoke this method.  This is called the '''return value''', and for this demon it is 'void'.  We shall speak more of this anon.
 
*** What the demon will give you when you invoke this method.  This is called the '''return value''', and for this demon it is 'void'.  We shall speak more of this anon.
 
*** The '''name of the method'''.  That is our primary concern today!  The only method for this demon is 'main'.
 
*** The '''name of the method'''.  That is our primary concern today!  The only method for this demon is 'main'.
*** What you will pay the demon.  This price is called the '''arguments''' of the method, and for this demon there is a standard price.  Not blood as you may think, but 'String[] args'.  These too shall be made clear as we progress.  You will notice that the '''arguments''' are enclosed in ordinary parentheses.
+
*** What you will pay the demon.  This price is called the '''arguments''' of the method, and for this demon there is a standard price.  Not blood as you may think, but 'String[] args'.  These too shall be made clear as we progress.  You will notice that the '''arguments''' are enclosed in ordinary parentheses.  If there is more than one argument, they are separated by commas.
** A '''signature''' can be recognized by residing within the class body and having a name followed by arguments enclosed in parentheses.  Betimes there will be a long list of arguments inside the parentheses.  Other times there will be no arguments but still there will be parentheses to show where they might be: '()'.  Fear not the complexity of the arguments; recognize only that they are enclosed in parentheses.
+
** A '''signature''' can be recognized by residing within the class body and having a name followed by arguments enclosed in parentheses.  Betimes there will be a long list of arguments inside the parentheses.  Other times there will be no arguments but still there will be parentheses to show where they might be: '()'.  Fear not the complexity of the arguments; recognize only that they are enclosed in parentheses and separated by commas.
 +
** Other important names of the '''signature''' include '''declaration''' and '''header''': these are synonymous.
 
* The second part of the '''method''' is called the '''body'''.   
 
* The second part of the '''method''' is called the '''body'''.   
 
** Just as the class body is enclosed in curly braces, so a method body is enclosed in curly braces.    And again, curly braces make a block and so a method body is a block.
 
** Just as the class body is enclosed in curly braces, so a method body is enclosed in curly braces.    And again, curly braces make a block and so a method body is a block.
 
** Method bodies contain statements and perhaps more blocks.  We will not concern ourselves with these now, except to use the ' System.out.println' incantations.
 
** Method bodies contain statements and perhaps more blocks.  We will not concern ourselves with these now, except to use the ' System.out.println' incantations.
  
==Discovering The Commands Of Other Demons==
+
==(B) Discovering The Commands Of Other Demons==
 
Refer once again to [[Hogwarts School Of Computer Science|The Mystery Of The Curly Braces]].
 
Refer once again to [[Hogwarts School Of Computer Science|The Mystery Of The Curly Braces]].
 
* What is the name of the class of this demon?
 
* What is the name of the class of this demon?
Line 35: Line 38:
 
* Gaze upon the names of the class and the methods: are there differences in the first letters?
 
* Gaze upon the names of the class and the methods: are there differences in the first letters?
  
==A Profusion Of Demons==
+
==(C) A Profusion Of Demons==
 
* Download ye the dread [http://www.skylit.com/javamethods-old/studentdisk.zip Student Disk], and install it upon your H drive.
 
* Download ye the dread [http://www.skylit.com/javamethods-old/studentdisk.zip Student Disk], and install it upon your H drive.
 
* Explore the myriad demons which reside therein, and examine their commands (methods.)  Can you delve into their mysteries?
 
* Explore the myriad demons which reside therein, and examine their commands (methods.)  Can you delve into their mysteries?
 
* Peer into studentdisk/Ch11/Exercises/Triangle.java, and seek ye the five methods therein.  One of them is different: it bears the same name as the class and thus has yet another difference from all the other methods?  Know thou this difference?  
 
* Peer into studentdisk/Ch11/Exercises/Triangle.java, and seek ye the five methods therein.  One of them is different: it bears the same name as the class and thus has yet another difference from all the other methods?  Know thou this difference?  
 
* We call such methods '''constructors''': they are special, and we will learn of them later.
 
* We call such methods '''constructors''': they are special, and we will learn of them later.
 +
 +
==(D) After Class Demonology==
 +
* Peer into studentdisk/Ch20/Teletext/TeletextList.java, and list the methods therein.  List also the number of arguments for each method.

Latest revision as of 12:57, 16 September 2013

Personal tools
translate