《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 Serial8 Chapters
The Chosen
Every 50 years 5 individuals are chosen, at random, to receive gifts of power, oriented toward their interests, in order to shake up the world order. The only restriction being that they be loners, seperated from every day society so as to give them a chance to develope their new found power before those who may seak to maintain the status quo snuff them out. Jared Thorne woke to find himself gifted with the Game Character subspecies. Although starting out weaker than other chosen,past and present, his potential is far greater.
8 90 -
In Serial6 Chapters
Chicken Is Eat
Bob is a chicken god and starts out as nothing but a farm animal. Not much to do, not very smart, and not very powerful. Later he visits the mighty CHICK-FIL-A and learns the ways of a true chicken god. Read to see his epic journey that is full of adventures.
8 131 -
In Serial7 Chapters
Peerless Grandmaster
Mu Linhua's mother Mu Shenhua was a famous Grandmaster, with peerless martial skills. To avenge her dead husband and brother, Mu Shenhua fought against Grandmasters and Great Generals from Yu Empire for nearly a decade. To survive the harsh life on the run, Linhua was trained from a young age of 3 in martial arts and Qi techniques by her mother. After settling blood debts, Mu Shenhua succumbs to her injuries and leaves Linhua a token and resources to settle in Great Wei Empire under the Mu family of generals they were originally part of. The Great Wei Empire was far past its greatness as it was broken into factions controlled by powerful families. The Emperor of Great Wei was aging as royals were engaged in the muddy political warfare for succession to the crown. Follow the journey of Linhua as she steps into an arduous journey through the Wei Empire as she works on the path to carve her name in history and realize her ambitions. Will she be able to create her legends, live up to her mother's and her own ambitions, and become a peerless Grandmaster... Credit for cover: Yuliana Honcharuk What to expect from this piece? > Rational MC > MC always eager to learn > A lot of fight scenes > Badass MC > Some scheming and plotting
8 155 -
In Serial90 Chapters
Forgotten for a reason
izuku Midoriya a normal boy till the age of four when he was abandoned in a forest by parents. Was left to die that is what he thinks he has been there for 12years.With no human contact he conquered the forest and became a king till a group shows up and disturbs his peaceI do not own my hero academiaI don't own any photos I put into the storyI drew the profile pichave fun reading
8 181 -
In Serial87 Chapters
Blood War (Book 1, the Halfblood Chronicles)
Nika, a halfblood vampire, faces conspiracies and dark magic during a hunt for her best friend - whose kidnapping has sparked a war between supernaturals. *****Lurking in the shadows of the human world are Daemonstri - beings akin to vampires, witches, werewolves, and other foul myths. Nika, a seventeen-year-old Daemonstri, has been alienated since birth for having "tainted" blood, and her only real family is her best friend Lu. So when vengeful shapeshifters kidnap Lu, she scrambles to the rescue. With the help of Ren, a guardian on her father's payroll, Nika uncovers shocking conspiracies about the Daemonstri government and even darker truths about herself. Bloody confrontations leave both Nika and Ren vulnerable to their growing feelings, while Lu's abductors execute horrifying plans. And should they survive the chaos of war, only one thing is certain: their world will never be the same.Book 1 of the Halfblood Chronicles[[word count: 100,000-150,000 words]]This story is now available on YONDER, the next-generation reading app from the Wattpad family. Download YONDER from your app store to start reading.
8 197 -
In Serial16 Chapters
BLIND LOVE ✔{Completed}
||❤COMPLETED❤||This is my first fic.I apologize in advance for any inaccuracies.✖This fic is written with only imagination✖[♥Taɛҡօօҡ Yօօռʍɨռ Naʍʝɨռ J-ɦօքɛ♥]~~~~~~~THANKS❤~~~~~~~
8 307
