Commanding The Demons
From Huben's Wiki
(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: | ||
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 { | + | 2 { // start of class body |
3 | 3 | ||
− | 4 static public void main(String[] args) | + | 4 static public void main(String[] args) // method signature |
− | 5 { | + | 5 { // start of method body |
− | 6 System.out.println("Hello world!"); | + | 6 System.out.println("Hello world!"); // statement in method body |
− | 7 } | + | 7 } // end of method body |
8 | 8 | ||
− | 9 } | + | 9 } // end of class body |
</pre> | </pre> | ||
Line 28: | Line 28: | ||
** 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 35: | ||
* 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. |