Hogwarts School Of Computer Science
From Huben's Wiki
Line 1: | Line 1: | ||
+ | [[Image:Welcome To Hogwarts.jpg]] | ||
+ | |||
''GLENDOWER: I can call spirits from the vasty deep.<br> | ''GLENDOWER: I can call spirits from the vasty deep.<br> | ||
''HOTSPUR: Why, so can I, or so can any man; But will they come when you do call for them?''<br> | ''HOTSPUR: Why, so can I, or so can any man; But will they come when you do call for them?''<br> | ||
Line 54: | Line 56: | ||
// Adjust the horizontal position of the banner: | // Adjust the horizontal position of the banner: | ||
− | xPos- | + | xPos = xPos - 1; |
if (xPos < -100) | if (xPos < -100) | ||
{ | { | ||
Line 81: | Line 83: | ||
* Start Dr. Java. | * Start Dr. Java. | ||
* Cut and paste the incantation Banner.java into Dr. Java. | * Cut and paste the incantation Banner.java into Dr. Java. | ||
− | * Use the file menu to save it to your H drive. Don't change the name from Banner. | + | * Use the file menu to save it to your H drive. Don't change the name from Banner. Dr. Java automatically knows what to call the file: you just tell it what folder. |
− | * Use the Edit/Preferences menu to check the "Show All Line Numbers" box. Go "oooo, ahhhhhhh!" | + | * Use the Edit/Preferences menu to check the "Show All Line Numbers" box. Click apply, and close the preferences box. Go "oooo, ahhhhhhh!" |
* Click "compile", then click "run". | * Click "compile", then click "run". | ||
* Enjoy the results! | * Enjoy the results! | ||
Now we play with it. | Now we play with it. | ||
− | * Look for numbers, and try to | + | * Look for numbers, and try to change them to make it run differently. You will need to compile and run to see your changes. |
* What numbers do what? | * What numbers do what? | ||
* Bonus if you can find how to make it hop instead of smooth scrolling. | * Bonus if you can find how to make it hop instead of smooth scrolling. | ||
Line 137: | Line 139: | ||
This incantation has not followed the rules of the curly braces, but will still work. | This incantation has not followed the rules of the curly braces, but will still work. | ||
+ | |||
+ | * Cut and paste it into Dr. Java, and save it as HelloGraphics. | ||
+ | * Run it: it should work. | ||
+ | * Now indent it properly so that it looks like Banner.java above. | ||
+ | * Run it: it should still work. | ||
+ | * What does that tell us about spaces in these incantations? | ||
+ | * Why then do we indent according to curly braces? | ||
+ | |||
+ | Let's do it the easy way now! | ||
+ | |||
+ | * Cut and paste it again into Dr. Java, so there is no indentation. | ||
+ | * Select all the code. | ||
+ | * Press the Tab key. What magic has resulted? | ||
+ | * If you have time, you can play with this program too. |