《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 Serial29 Chapters
Alpha Daryl Reeds
He was feared by everyoneShe was loved by everyoneHe was cruel She was kind He was feared by most She was loving to most He destroys everything he touchedShe was the light everyone needed*******Daryl Reedus was the most powerful Alpha there was in small town Ashville, Joyce Dyer was shy and quiet, sassy when needed, but loved by almost everyone in her pack. When an attack brings Daryl to her pack she does everything to help fight him away, little does she know that he'll end up her mate.And little does he know he'll make his life hell if she doesn't get what she wants. Can Daryl make her fall for him? Will Joyce find it in her heart to love the monster everyone thinks he is?
8 251 -
In Serial19 Chapters
Time-Leap With Certain Possibilities
This story is of a Certain Boy whose life changed drastically after an attempt of Time Travel which caused him to jump in Another Dimension and who would have thought that this boy was the one who was going to save the whole world.
8 176 -
In Serial7 Chapters
How Will This Work?
What if there were human-animal hybrids, dog-hybrids are seen as above the other hybrids. Mainly cat-hybrids...So what if Percy is a catboy, but some how shows up in the army. How will he bet all expectations, and what is he hiding?All character belong to Rick RiordanP.S. Might change to mature later on... I don't know yet
8 214 -
In Serial16 Chapters
Spire: Clan of the Holy Fortress
Introduction -Santiago Fortino Alocarta Seza was just ten years old when the great spires struck the oceans of Earth creating tsunamis that flooded the coastal regions of all of the seven continents of the world. Aside from the great destruction the spires also brought with them a wave of radioactive energy that could be felt by all but no instrument could detect washed over the lands. This energy generated “The Great Awakeningâ€, a phenomenon that cost many lives killing hundreds of thousands. Those that did not die from this event awoke from within themselves power to manipulate forces and move objects with their minds.Then the spires flooded the world once more with creatures of various forms throwing the world into chaos as they began to slaughter mankind. Man with time fought to victory and on beyond the mudball called Earth reaching other stars to make war or colonies. Santiago was there from the beginning but this is not the story of his many deeds in his first lifetime, this story is about his second chance. His redemption.
8 198 -
In Serial12 Chapters
243 Wanderers
My name is Karasuma Eiji, a boy abandoned by my parents, and getting picked up by your everyday ordinary drug dealer. And on one particular day, I got careless and got caught when I was delivering the package. After that incident and spending some time in the juvenile and rehabilitation centre, and getting re-educated. By the time I reached the age to enter a high school, I finally had the opportunity to go out of the system and take my freedom with terms. I must attend and finish the boarding school without adding a single bad record. But at the entrance ceremony, my world suddenly changed. The whole 1st-year student is summoned into a fantasy world in order to defeat the demons and become a hero. However, why do I want to do that? What's the benefit? Is it Money? Then how much? Is it Fame? Or just plainly returning home after everything was over? What about our safety? Is there any insurance? And what should I care? This isn't my world nor do I have any special bond with this world.
8 128 -
In Serial59 Chapters
Otome game in a reality
She died and found herself in a world of a game. The japanese game called 'Only mine' otome game. She thought it was a simple dating game so didn't take it seriously. She simply thought making the capture targets fall in love with her will lead her to victory. But soon she realized just how dangerous it is to not know anything about the word 'yandere'. A simple word she didn't pay any mind to when reading the informations of capture targets will lead her to a disastrous road. What will she who knows nothing about otome game or even a yandere would do to win the game? And who is the capture targets? Will she be able to go back to her world? Read to find out more.#1 in obsession 07/31/2020#1 in yanderemale 08/01/2020#2 in possessive 08/02/2020
8 187
