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
The Knowledge Of Sauron's Minions - Huben's Wiki

The Knowledge Of Sauron's Minions

From Huben's Wiki
Jump to: navigation, search
(Created page with "Welcome to Rivendell! You have completed your stay at Hogwarts and have come here to study Java even further, to learn the dark secrets of Sauron. Sauron knows whatever his ser...")
 
Line 1: Line 1:
 
Welcome to Rivendell!  You have completed your stay at Hogwarts and have come here to study Java even further, to learn the dark secrets of Sauron.
 
Welcome to Rivendell!  You have completed your stay at Hogwarts and have come here to study Java even further, to learn the dark secrets of Sauron.
 +
 +
==Revealing The Knowledge==
  
 
Sauron knows whatever his servants, the RingWraiths, know, thus it is essential to learn of the types of knowledge RingWraiths and other fell classes can possess.
 
Sauron knows whatever his servants, the RingWraiths, know, thus it is essential to learn of the types of knowledge RingWraiths and other fell classes can possess.
Line 7: Line 9:
 
public class RingWraith
 
public class RingWraith
 
{
 
{
 +
  // variables
 
   static public int iAmOneOf = 7;
 
   static public int iAmOneOf = 7;
 
   static public double myAgeIs= 2734.81;
 
   static public double myAgeIs= 2734.81;
   static public char exclaim = "!";
+
   static public char exclaim = '!';
 
   static public boolean iBearARing = true;
 
   static public boolean iBearARing = true;
 
   static public String iServeTheDarkLord = "Sauron";
 
   static public String iServeTheDarkLord = "Sauron";
 
    
 
    
 +
  // methods
 
   static public void main(String[] args)
 
   static public void main(String[] args)
 
   {
 
   {
Line 23: Line 27:
 
}
 
}
 
</pre>
 
</pre>
 +
There is only one method, main(), in this RingWraith class: the other statements at the beginning declare '''variables'''.  The five variables here are the most frequently used sorts.
 +
 +
There are many '''basic types''', but here we shall concern ourselves with only four.
 +
 +
If you wish to represent an integer, then your variable should be of the basic type '''int'''.  Yet even evil has its limits: an int variable can only represent numbers up to about 2 billion and down to negative 2 billion.  We will delve into that mystery later.
 +
 +
If you wish to represent a real number, to have decimal points, to calculate fractions, to cleverly calculate the moon and sun, then you must use the basic type '''double'''.
 +
 +
The basic type '''boolean''' is the simplest of all yet represents the atom of all calculation, all knowledge: it can represent only true or false.  All else can be built of boolean, but the labor is extremely difficult.
 +
 +
Betimes a single character must be represented, thus the basic type '''char'''.
 +
 +
Type '''String''' is not a basic type: it is a '''class''' and variables of type String are called '''objects'''.  String is one of the important classes that come with Java, and one of the most frequently used classes.
 +
 +
==Further Revellations==
 +
 +
* Trap the RingWraith code within Dr. Java.
 +
* Note the different colors of the code.  What could they signify?
 +
* Pull down the Dr. Java menu and select Preferences.  In the Categories section, select Display Options and then Colors.
 +
* Make a note of how you find each color (from Normal Color to Brace-matching Color) in the code.
 +
* Brace-matching Color is tricky.  How do you reveal it in the code?
 +
* I can hardly see the Type Color in the code.  Click the ellipsis (...) button to the right of Type Color, and change the color to a dark red.  Click Apply and OK.  More visible now?
 +
* '''Keyword''' means the same as '''reserved word'''.  We have one of these magic words posted on high: which others should we add now?
 +
* The basic types are also reserved words: what else then should we add to our list of reserved words?
 +
* Why shouldn't we add String to the reserved words?
 +
* Look at the variable names.  What pattern of capitalization do you observe?
 +
* Each of the variables is SET with a value.  These written values are called '''literal constants'''.
 +
* The exception is boolean: '''true''' and '''false''' are reserved words.
 +
 +
==The Arcane Knowledge==
 +
* Add another variable to RingWraith, of type double and named "compute".
 +
* Inside main(), add 'compute = Math.sin(Math.PI/6);'
 +
* Print out the value of compute with the proper incantation.
 +
* Look on my page for "References", and click on Math.  Explore therein and find the secrets of exponentiation and other precalculus functions.

Revision as of 10:10, 21 September 2012

Personal tools
translate