《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 Serial15 Chapters
Tales of the Dragon God
Synopsis: House Vjorn is one of the founding Houses of the City of Trênt - The Final Frontier of North. Skye, the heir of the House lived a sheltered life until one day everything changed. He was fated by the dragons, a fate that only occurs once in a millenia and rivals the mythical creatures themselves. But the constant threats of a shadow organization that hunts people like him forces him on a long and arduous journey . Assasination, wide scale war, fights to the death, battle of wits, legendary duels and more await him on his travels as he tries to reach the pinnacle of existence. Let the Tales of the Dragon God begin- Prolouge: A dragon spanned his wings in full length furiously to propel himself further. Faster, he needs to be faster. A glowing black ring with runes etched in golden light appeared and hovered through his back as if a halo of an angel."Curse of Speed" he muttered under his breath and he zoomed through the horizon in a fashion no other dragons may dream of. "I need more speed or that damned thing might catch up to-" he said with a loud growl but before he could finish he saw a golden ring flash by only to stop at a few feet in front of him. A boy with black hair stood in front of him. Darkness enveloped his whole body, while the robes he was wearing was somewhat darker than the darkness. It was like he was staring to an abyss only to be swallowed by a void, an endless one at that. The only tinge of light came from the golden ring above his head. He looked at his face but he can't see any features that he could describe. Then his eyes wandered at the golden ring above his head. His sky-blue draconic eyes glowed with a golden hue. Looking closer, the ring was actually a crown embroided in sophisticated runes that even him a hundred thousand year old dragon cannot comprehend. "A million year old ring. It can't be that you killed-" but again, before he could finish dark ice formed in his snout gently crawling to his eyes. He retaliated by breathing his icy breath but even the absolute ice was frozen by the abyss black ice magic that was crawling through his body. And like the color of ice, darkness came upon him to never awake an eternal slumber. Death took over and a golden ring etched with black colored runes hovered above his corpse. Author's note: Hi! Xiaoma here, thanks for checking out my story. I am new to writing fictions but im excited to work my magic on my very first novel. I've currently set my goal at 10,000 words per week but I might increase that when my schedule allows me to do so. Hope y'all enjoy! Warning: Planning to add BL (similar to Yaoi minus the sex scenes) and Yuri (girls liking girls) contents ahead. Read at your own violition.(Do not read if you're extremely homophobic)
8 173 -
In Serial14 Chapters
Quiet Tales of a Forgotten Reaper
This is Bob. Bob is a reaper. Here to claim souls and tell stories. Bob likes telling stories. (Wait. Hold up. Stop right there. Hi I'm Bob nice to meet you. My author tries to be funny. But you know try and try again right? I will be the one telling you the stories not this guy. Hopefully you will enjoy them. Anyway I suppose I will let him continue.)I won't bore you with the small details. Lest we forget that Bob is the one telling the stories here. However some things must be known. There are multiple stories each with it's own theme. The Intro is basic and there is not much to it. Senna is a girl in a fantasy world. Oh and I am the Author. It's nice to meet you.A.N. The cover right now is just a temp pic i drew a while back i will be posting a new one eventually.
8 268 -
In Serial17 Chapters
Thane’s War
The United States, having lost the backing of half of NATO, stands against a Unified Front of Iran, People’s Republic of China, North Korea, and many smaller nations. After two years of war. First Lieutenant Jason Thane, a war hero and survivor of one of the deadliest campaigns ever seen in modern war, returns home from his first deployment. Jason may have returned home, but his mind is still at war, and as he attempts to navigate this horrible situation he finds himself in. Something has happened in Elkhart, Pennsylvania. Jason’s leave is cut short as he must once again fight. But this new enemy is nothing like Jason has ever seen before.
8 130 -
In Serial8 Chapters
The Untamed Mates
One Dark , One light. One protected her. The other loved her. But in the end, she'll have to choose. No matter who will she chooses, her soul will be ripped apart forever. Eva, a eighteen years old girl, wants a simple life after her parents death. But her life turns upside down when she started urban academy. Rich and high class brats are trained here. They think Eva have supernatural powers which can both save and destroy thier world. She have to find a way to survive.
8 174 -
In Serial29 Chapters
My Abusive Husband|P.JM✔️
"You disobeyed me again baby girl...now watch how I hurt you."
8 339 -
In Serial38 Chapters
4 Letters Long [OHSHC]
Kaoru x OCAkane Yukimura and her brother, Yoichirou Yukimura transfer to Ouran Campus upon Shizue Suoh's, Tamaki's grandmother, request in return for Akane who saved her life.Akane and Yoichirou have not led an easy life for their past five years. But when they come across the Ouran High School Host Club, things start to turn to the lighter side.
8 63
