《Programming Wizards!》Gyroplane
Advertisement
“A friend of mine returned from an expedition yesterday.” The students attentively listened, for stories from beyond Rorohiko were rare. “They flew over a forest in a gyroplane.” He looked around. “Does anyone know what a gyroplane is?” He pointed to a student with his hand raised.
“A vehicle capable of flying in any direction or hovering in place using its propellers.”
“Yes, what is your name?”
“Roy.”
“Roy, do you know how we can keep its propellers turning?”
He thought for a moment, then shrugged. “I’m not sure what you mean.”
“How can we run code repeatedly?”
He thought some more. “Wouldn’t you have to keep executing the code again and again?”
“Yes, do you know how to write that in code?”
“No, unless you’re about to teach us how to do it at runtime.”
Vick smiled, he knew this class was different. “Yes. Today, you will learn how.”
while (true) { Console.WriteLine(“Looped!”); }
“Above me,” he pointed to the screen, “is a ‘while loop.’” He executed the code. ‘Looped!’ it said. Then, on the line under it: ‘Looped!’ Then, on the line under that: ‘Looped!’ Then, over and over and over. “It will continue to execute as long as its condition is true. What we’ve created is an infinite loop.”
int i = 0; while (i < 5) { i = i + 1; Console.WriteLine(“Loop #” + i); }
He ran the code, and after displaying five lines, ‘Loop #1,’ ‘Loop #2…’ the program completed its execution. “The condition is checked before the execution of the loop. The loop is only executed if the condition is true. What we’ve made is essentially a ‘for loop.’”
Advertisement
for (int i = 0; i < 5; i = i + 1) { Console.WriteLine(“Loop #” + (i + 1)); }
He ran the code again, and it displayed the same five lines. “Instead of declaring an integer beforehand, and incrementing it in the loop, we can declare it, condition it, and increment it in a single line. That’s the power of a for loop. Note how we add one to the variable ‘i’ before concatenating it. This is because, in a for loop, the increment occurs after the loop’s execution. Whereas, before we incremented ‘i’ at the start of the loop.”
do { Console.WriteLine(“Looped!”); } while (true);
“The last loop is similar to a while loop,” he raised a finger, “with one important distinction. It executes at least once. Meaning, it executes once, then evaluates the condition to figure out if it should execute again. This is a ‘do while loop.’ Or simply, ‘do loop.’” He looked over the class, looking each student in the eye. “If you are to become apprentices, you must be wary with your use of loops.” His voice was uncomfortably firm, almost grim. “We will entrust you with precious resources, if you accidentally make an infinite loop where resources are expunged, there will be grave consequences.” He diverted his attention back to the computer. “Now, what does this have to do with gyroplanes? Well, their propellers need constant energy to spin.”
bool isOn = true; while (isOn) { Console.WriteLine(“Spin!”); }
‘Spin!’ said the screen over and over. “Yes, it is an infinite loop. However, another process would be occurring between each loop. That process would detect if a button was pressed which toggles the boolean. When that button is pressed, the loop will evaluate its condition as false, stopping it.”
Advertisement
for (float speed = 1f; speed < 20f; speed += 2f) { Console.WriteLine(“Spinning at speed: ” + speed); }
“The ‘f’ letter at the end of the numbers is to indicate it as a float in this language, not to be confused for an integer. The speed of the propeller can be controlled with each execution of the loop. Begins at one, only executes if it’s below twenty, increments by two every loop.” He walked closer to the class and stood taller. “Because of our great wizards, we were able to construct hardware that made it impossible for a propeller to spin too fast. So, even if we made an error where the speed became an enormous number, the propeller would simply rotate at its max speed dictated by its hardware. Just as integers and floats have a min and max range, so does the speed of a propeller. Zero being its min, and around four-hundred being its max.”
“What does ‘speed += 2f’ mean?” asked Willard.
“That’s shorthand for incrementing by two, and then setting that value to the variable.”
After class, the three huddled to converse. “Hey,” said Willard. “Does anyone know what a forest is? I heard Mister Vick use that word.”
“I’m not sure,” said Andrew, and Gus shrugged.
“It’s a massive cluster of trees,” said Roy, from down the hall, and walked towards them.
“Like, five or so?” asked Willard.
“No,” said Roy and stretched his arms to his sides. “A thousand kilometers, maybe more.”
Everyones’ jaw dropped. “What?” said Gus.
“A thousand kilometers? That’s impressive,” said Andrew.
Advertisement
-
In Serial128 Chapters
Unfamiliar Faces(Completed)
Live a long enough life and boredom becomes the enemy. Live a strange enough life and you start to crave a little more normalcy. Old Monty has been around for quite a while. Long enough for all his enemies to have either died off or gotten over whatever they were mad about. Long enough for all his friends to have either moved on or moved up to higher planes of existence. For eons he slept, unbothered, unprovoked, unremembered. Now a whole new life is knocking at his door. A whole new adventure as the familiar of an intrepid but callow young mage. Can a immortal lord of the void lower himself to being a mortal's partner-in-crime? Yes. Will there be some good stupid fun along the way? There better be...Or the whole world might be in trouble.
8 191 -
In Serial47 Chapters
The Lost One
At 19, life has given Aislinn Nox many things, most of them she never wanted. Like dead parents at the age of six. Scars.A slaughtered pack.Nightmares. To be forced to live with humans. Thirteen years of hell. A new name.An old legacy. All of them are hers, all of them have broken her, but none of that will matter when she finally gets the one thing she desires: revenge.For five years she has been planning her revenge for the brutal murder of her parents, and the vicious slaughter of her entire pack. And for five years, it has been all that she has lived for.And nowhere, in those neat little plans did she included a pack, friends, a mate she could never deserve, or remembering everything and everyone she lost. But life is cruel. And rarely do we get what we want. ..Kaiden Salvatori is the first born son of Alpha Sergio Salvatori, who thought he had life all figured out. He was easily learning the ropes of the family business, taking over his roles both in the pack as Alpha, as well in the corporate world as a powerful CEO. It was all simple and predictable, boring even.But that all changes in a single night when he happens to stumble across a she-wolf being hunted on his territory, discovering that not only is she a rogue herself but that she also happens to be his mate...In that one fateful encounter everything changes. Lies will be uncovered. Truths revealed. Enemies exposed.When secrets and betrayals come, both Kaiden and Aislinn will be forced to choose; what are they willing to give up, and what they are prepared to fight for. Fate has destined them for each other, but sometimes even that just isn't enough.©The Lost One (2015)
8 144 -
In Serial53 Chapters
The Purple Jade Palace: Prince Yernal's Plan (Book Two)
Now a prisoner in the Keglar Kingdom, Teal is desperate to escape and bring justice to the Talbecan Empire. Fortunately, Teal has more allies than he realizes. But bringing down those who have worked against the Talbecan Empire is going to be very difficult, and he just might need to find his fellow Lombocks to help him. I am going to post another chapter around the 8th of July. However, I work fulltime and I'm a mum, so I want to make sure I don't fall behind at any point so I will be posting once a fortnight. After the 8th of July, I will be post on the 22nd of July (give or take for time differences) :))
8 121 -
In Serial9 Chapters
THE NUMBERS: RON THE 63
RON: is one of the best assassins in his world his codename is *the red Abomination* ranks 63his family are assassins and killers his father codename *the God of death* ranks 0 and his mom *the mad one* ranks 1 his family is in the thousandhe Only knows two of his spellings, his older brother's codename *the dark crow* rank 20, and his older sister's codename * the singer fox* his life is fine tell his father was trying to eat him He has survived three times. The first time was when his father put him in the fridge after he seasoned him But his brother saved him, and the second time, when his father put him in an oven, his brother saved him againThe last time he was in prison and dropped the soap, his brother saved himAfter the last accident, he lived a full life of escaping and killing tell one day one of his father's followers find him codename *the doctor* rank 21* the doctor*: wow you are really an abomination look at you a cat ear on the left and a wolf one on the right and foxtail and your green eye is like a Beast eye good Thing you have one eye and your rank 63 for a 10-year-old hell kid now I believe you are the boss son the boss want you alive but you are dangerous for this goodbye *bang* *bang* *bang* Ron He was shot three times, once in the heart, once in the liver, and once in the head Ron looked at his killer and He closed his eyes for the last time, or as he thought
8 205 -
In Serial31 Chapters
Engagement [Book 3: SEKTOR V Trilogy]
Highest WP ranking so far: Sector #1 (out of 1200) Top 0.08%In the epic culmination of the SEKTOR V Saga, the final vestiges of Humanity are scattered across the far reaches of the galaxy. After the apocalyptic loss of their homeworld a century earlier, Maddy, Gus, and Næsta Kynslóð scientists emerge from their Black Hole-orbiting cocoon. Joining forces with ET allies, Colonial settlers, and a teenage prodigy, they race to save Humanity from the crushing galactic grip of the Zeta Alpha Draconian Coalition.With the odds stacked heavily against them and time running out, the Terran Alliance must coalesce in a last-ditch effort to end Zeta oppression and free the Humans and Hybrids enslaved on Earth.
8 190 -
In Serial9 Chapters
Accidentally traveling in the beastworld novel!
Elsa is an half european and half Asian,she is a very beautiful women.On day she accidentally fell asleep in the during dinner and when she woke up she found her self inside the novel that she have read .She traveled inside the novel of called "Beauty and the Beasts ".How will she survive in this new world"
8 206
