tag:blogger.com,1999:blog-32227956932895455322024-03-13T10:11:20.736-04:00Gregory DesrosiersUniversity of Waterloo, Software Engineering 2AGregory Desrosiershttp://www.blogger.com/profile/00189273846619965757noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-3222795693289545532.post-82498886744081172892014-06-24T16:31:00.003-04:002015-08-18T19:50:36.537-04:00Rock Paper Scissors Lizard Spock (JAVA Program)<title>Rock Paper Scissors Lizard Spock (JAVA Program)</title>
It's time for another JAVA program to exhibit for new programmers; this time, with Rock Paper Scissors Lizard Spock!<br />
<br />
It's another fine day here in the countryside outside of Montreal. We got gorgeous sun right above us, even though yesterday was technically the summer solstice, in which now I'm feeling kind of down because I wasn't able to get together with my friends and have a wonderful time hanging out; it's a way for me to earn a better self-esteem and social living, because eventually I'll be with multiple classmates at University of Waterloo.<br />
<br />
In case you're wondering about me with the FIFA World Cup 2014, technically I'm not watching it because I am more interested in paying attention to video games and working on building massive audiences for crowdfunding and public attention. In addition, I don't have enough money to build a concert at my town, participate in a drama or vocals show, join up with a television team, or even learn the secrets behind mass media and how to earn attention and promotion.<br />
<br />
Anyway, what I want to show you today is a program I've worked on last night that I have just completed; it's a way for me to get my intelligence in JAVA back because I'll need to use programming and different kinds of talent from my time at college to be used in my first-year classes at University of Waterloo. It won't be easy, but with the kind of advice and treatment, I can earn a wonderful time and be so integrated with the people around me.<br />
<br />
This is my own text-based program of Rock-Paper-Scissors-Lizard-Spock, which is a change in Rock Paper Scissors, and it was created, according to Wikipedia, Sam Kass and Karen Bryla. It was used in one episode of the Big Bang Theory; Raj and Sheldon did this kind of draw to decide which show they should watch together. Sheldon is up for Saturn 3, while Raj is up for Deep Space Nine. After Sheldon gives out the details of the draw with some non-verbal communication to show which sign is which in the game, he and Raj give out a shot in which they both end up using Spock.<br />
<br />
Here's what Sheldon said, which is pretty much the details of the draw (originally written by teleplay writers David Goetsch and Jennifer Glickman): <b><a href="http://bigbangtrans.wordpress.com/series-1-episode-08-the-lizard-spock-expansion/" target="_blank">"Scissors cuts paper. Paper covers rock. Rock crushes lizard. Lizard poisons Spock. Spock smashes scissors. Scissors decapitates Lizard. Lizard eats paper. Paper disproves Spock. Spock vaporizes rock, and as it always has, rock crushes scissors."</a> </b><br />
<b><br /></b>
The program I wrote is a console-based application; all the graphics used in this implementation are Unicode characters predetermined within the Java Virtual Machine. What I'll do is show you a quick visual example of how the program works, and then I'll give you the code for it. Take note that I'm running this program on an IDE called Eclipse Kepler; more specifically, Eclipse JAVA EE IDE for Web Developers.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-6r1n0gWlLaQ/U6dEiw0XiOI/AAAAAAAAAY8/JVyb4URjSfo/s1600/First+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://1.bp.blogspot.com/-6r1n0gWlLaQ/U6dEiw0XiOI/AAAAAAAAAY8/JVyb4URjSfo/s1600/First+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">In starting the program, we get a two-second pause before we get a message saying the computer makes its move first. And then after another two-second pause, we get a message to enter a character corresponding to one of the five different moves of this game. Type in either, 0, 1, 2, 3, or 4, and press the Enter button.</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-mqxVX0vQbGo/U6dEk6oe8UI/AAAAAAAAAYk/NAJMImMnuWU/s1600/Second+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://3.bp.blogspot.com/-mqxVX0vQbGo/U6dEk6oe8UI/AAAAAAAAAYk/NAJMImMnuWU/s1600/Second+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Typed in 0. Oh, too bad; the CPU wins. Paper covers rock. Time to play again!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-T8x5xwpBivA/U6dElZ0dNUI/AAAAAAAAAY4/D6vLTAVRjGA/s1600/Third+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://3.bp.blogspot.com/-T8x5xwpBivA/U6dElZ0dNUI/AAAAAAAAAY4/D6vLTAVRjGA/s1600/Third+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Computer goes first again; time to type in our move!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-EAL4KmOjTJE/U6dEkvgkiEI/AAAAAAAAAY0/a4Nvo_ZFQ3U/s1600/Fourth+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://1.bp.blogspot.com/-EAL4KmOjTJE/U6dEkvgkiEI/AAAAAAAAAY0/a4Nvo_ZFQ3U/s1600/Fourth+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Type in 6: error. Type in 55: error again! Pay attention to the messages!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-w-6NEMsrros/U6dEijcM-aI/AAAAAAAAAYM/7JsfH-RWYuk/s1600/Fifth+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://1.bp.blogspot.com/-w-6NEMsrros/U6dEijcM-aI/AAAAAAAAAYM/7JsfH-RWYuk/s1600/Fifth+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">I type in 4, as in Spock, and it looks like I win! Spock vaporizes rock!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-GvXrJBOh8sw/U6dElR0D-nI/AAAAAAAAAYs/RDWjWdqj92M/s1600/Sixth+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://3.bp.blogspot.com/-GvXrJBOh8sw/U6dElR0D-nI/AAAAAAAAAYs/RDWjWdqj92M/s1600/Sixth+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">After asked to play again, in which I do, I type in nothing at the start. Ah, error detected! And so now, I type in 3, where I make my stance for Lizard.</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-ZX1ZLwZIPuQ/U6dEk8bfrFI/AAAAAAAAAYw/nWKfZFHtyzc/s1600/Seventh+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://2.bp.blogspot.com/-ZX1ZLwZIPuQ/U6dEk8bfrFI/AAAAAAAAAYw/nWKfZFHtyzc/s1600/Seventh+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Oh, dear! It looks like we have no winner! One last try in playing!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-1qiIV2nQGmE/U6dEiuBbEEI/AAAAAAAAAYc/QaQp2XwD8h8/s1600/Eigth+Screen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="179" src="http://1.bp.blogspot.com/-1qiIV2nQGmE/U6dEiuBbEEI/AAAAAAAAAYc/QaQp2XwD8h8/s1600/Eigth+Screen.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">I make my move for paper, and I win. Paper disproves Spock. And it looks like I don't want to play again, so it's quit, and good-bye!</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
With the photographs now out of the way, let me share with you now the source code of this program and how it actually works. Modifications are done so that way you can see what it is I'm talking about.</div>
<br />
To make understanding much easier, let me give you a description of what you are expected to see in the source code of this program. I've colored-coded the elements of the code so that way as soon as you see them the first time, you'll know what is that feature and what color is used to distinct it.<br />
<br />
The text highlighted in black is the details on how the full program works. The text highlighted in dark green are technical details.<br />
<br />
<div style="font-family: Consolas; font-size: 13px;">
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">This is the source code of this text-based Rock Paper Scissors Lizard Spock program. There are other ways to implement this, but this is how I've implemented it myself. These are the instructions you feed into the Java Virtual Machine to execute and perform. Feeding instructions in any computer involves a programming language.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Programming has so many worldwide applications that it is now part of most of natural and service jobs all around the world. The biggest use of programming is, of course, in the computer gaming and telecommunications industries.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Anyway, let's continue on with going through the source code.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;">// Written on June 21 - 22, 2014</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;">Anything you see in a greenish color with two forward slashes is a single-line comment. You can write anything in a single-line comment as long as two forward slashes precede it. Usually, when you type in something in a source code file, the compiler is supposed to compile everything that's in the file. However, the compiler ignores comments, just as long as there is a combination of symbols to denote which is which.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<b><span style="color: blue;">import</span></b> <span style="color: #93c47d;">java</span>.<span style="color: #93c47d;">util</span>.<span style="color: #bf9000;">Random</span>;</div>
<div class="separator" style="clear: both;">
<b><span style="color: blue;">import</span></b> <span style="color: #93c47d;">java</span>.<span style="color: #93c47d;">util</span>.<span style="color: #bf9000;">Scanner</span>;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Any word highlighted in blue is a keyword. Text highlighted in olive is a package name, since certain instructions can be stored as data recipes, or classes, on their own. And a name in tan is a class name.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Here, we're loading access to two different classes, Random and Scanner. Because the default package used in JAVA programming is java.lang., we must import other packages if we want to consider using a specific class belonging to those individual packages. Simply put, it's to let the compiler know, "Okay, this code requires the use of those classes," and thus the libraries holding those classes are loaded into the compiler accordingly.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">java.util.Random is a programming entity containing methods that return a value by using randomization algorithms. java.util.Scanner is a basic data entry for file input, or keyboard input through the console.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<b><span style="color: blue;">public class</span></b> <span style="color: magenta;"><b>RockPaperScissorsLizardSpock</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><b><br /></b></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">"RockPaperScissorsLizardSpock," colored in pink, is the name of the main class for which the compiler is to convert text into a binary format compatible with the Java Virtual Machine.</span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;">"public" is an access specifier, on the fact that in object-oriented programming, instructions are to interact with the main code of other classes, as well as the objects that these classes may store on purpose.</span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;">"class" is pretty straightforward; it's simply telling the compiler that there is a data recipe to be compiled.</span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: #274e13;"><span style="color: white;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">In JAVA, any program that has an execution method is defined as a class; simply, a blueprint of what is to be instantiated during execution.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// Constants</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static final</span></b> <span style="color: #bf9000;">String</span>[] <i><span style="color: purple;">CONSTANT_MESSAGES</span></i> =</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">A name italicized and purple is a static variable. Because we have a constant where the value assigned to that variable is not changed at all, the name is also in capitals.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">The keyword "final" is to tell the compiler that the value assigned to the variable is a constant and cannot be changed any way during execution.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Instead of using multiple String variables, or constants, for use in the program, to offer some flexibility and easier handling, most of the messages used in the program are stored in this pre-assigned String array.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">This array holds most of the messages you see during gameplay. It's designed to have a bank of messages, all carefully indexed and categorized, so that way there can be more than one message of the same thing accordingly. This opens flexibility for the computer to decide randomly which message to use for the particular phase of the game.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Who goes first?</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Anything in orange is a comment block. Like single-line comments, the compiler ignores it as long as you have the proper syntax for it. Start with /*, and end with */. The advantage of a multi-line comment block is that you won't have to type in // for every single line. All you have to do is make sure that the comments are typed preceding the tag */.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Anything you see in red is a string literal. A string is a computer entity consisting of a character or more, including special Unicode characters.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// Player goes first (0 - 6)</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You make your move first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"I'll let you go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Go for your move!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Why don't you go first?"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Please, make your first move."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Alright, let's see what your move is."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// CPU goes first (7 - 15)</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Why don't I go first?"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"I'm going first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"I go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"I shall go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"It will be my prior to make a move first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You let me go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Mr. Computer shall go first."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Your CPU decides what move to pick primarily."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Let's see what my move will be..."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Winner Messages (16 - 20)</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Awesome; you win! "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"CPU surrenders! "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"White flag for the CPU; "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Winner! "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"WIN. "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Loser Messages (21 - 25)</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Too bad, you lose! "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You lost. "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You lose! "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"You are forced to surrender. "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"LOSE. "</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * No Winner Messages (26 - 31)</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"No winner in this case!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"We have a draw!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"It looks like no one wins!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"No winner!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"A winner is ceased to exist!"</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Uh-oh, no winner."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Command Messages (32 - 41)</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Scissors cuts paper."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Paper covers rock."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Rock crushes lizard."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Lizard poisons Spock."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Spock smashes scissors."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Scissors decapitates lizard."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Lizard eats paper."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Paper disproves Spock."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Spock vaporizes rock."</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: red;">"Rock crushes scissors."</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>};</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13; white-space: pre;">Anything that is colored in light blue is a number literal.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static final byte</span></b> <i><span style="color: purple;">CHOICE_IS_ROCK</span></i> = <span style="color: #3d85c6;">0</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><i><span style="color: purple;">CHOICE_IS_PAPER</span></i> = <span style="color: #3d85c6;">1</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i> = <span style="color: #3d85c6;">2</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><i><span style="color: purple;">CHOICE_IS_LIZARD</span></i> = <span style="color: #3d85c6;">3</span>,</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><i><span style="color: purple;">CHOICE_IS_SPOCK</span></i> = <span style="color: #3d85c6;">4</span>;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">"byte" is a primitive data type, in the sense that it is directly stored in the RAM as a sequence of bytes without using a reference address. In JAVA, most of the primitive data types are signed, and thus a variable of type byte can hold a value between -128 and 127.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">In this program, the values 0 to 4 are used to represent the five different movements a player can make in Rock Paper Scissors Lizard Spock.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static final</span></b> <span style="color: #bf9000;">Random</span> <i><span style="color: purple;">aiObject</span></i> = <b><span style="color: blue;">new</span></b> <span style="color: #bf9000;">Random</span>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static final</span></b> <span style="color: #bf9000;">Scanner</span> <i><span style="color: purple;">keyboardInput</span></i> = <b><span style="color: blue;">new</span></b> <span style="color: #bf9000;">Scanner</span>(System.<i><span style="color: purple;">in</span></i>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13; white-space: pre;">Although the objects aiObject and keyboardInput are static constants where their variable names should be capitalized and the underscore is used, they are left in conventional format for variables that are not constants because </span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static void</span></b> <b><span style="color: #783f04;">main</span></b>(<span style="color: #bf9000;">String</span>[] <span style="color: lime;">args</span>)</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Any text preceding the left curved bracket, or left parenthesis, and colored in a maroon-like brown is the name of a method. Except for static variables, text colored in light green is an object reference pointer, or reference variable.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">This is the header of the prime method the JVM executes upon running: the "main" method, with an array of command-line arguments passed as the method argument. When you run your program through the computer terminal, such as Command Prompt on Microsoft Windows, any additional text you add, separated by spaces, after the name of the class file to execute, are the arguments that this method takes in.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">You don't necessarily have to type in a command. In this case, there is no command to type in for the functionality of the program, so what happens is, this array is created, but of fixed size 0.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">"void" is a return type for a method, where the method is not forced to return a value or a reference address. Primitive data types, arrays, and names of classes from respective packages are compatible as return types of methods.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Declaration and Construction Phase</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="background-color: white;"><span style="color: #bf9000;">String</span></span> <span style="color: lime;">messageString</span>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">byte</span></b> <span style="color: #666666;">playersChoice</span>, <span style="color: #666666;">computersChoice</span>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">boolean</span></b> <span style="color: #666666;">playAgain</span> = <b><span style="color: blue;">false</span></b>;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">There are only two values used in a boolean variable: true, and false.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Text colored in gray is a primitive data type variable. Text in black is therefore syntax.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// Starting Message</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"Hello there!"</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">"Hello there!" is the first message you see in the output of this program.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #783f04;"><b>pauseProgram</b></span>();</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">As soon as the first message is displayed, this program is paused for about two seconds by calling this method. </span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">do</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"> /*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Input Phase</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">The first thing the program does is, it makes a draw to who should go first and make their move. Technically, both players choose a move instantly, but because the computer needs to register the player's input, which does take some time, the input is sequential instead of instant. As such, we want to deal with two different kinds of input and processing, but the rules of the game are definitely followed anyway because the outcome is not displayed until the very end.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextBoolean</b></span>()) <span style="color: #38761d;">// AI goes first</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<span style="color: purple;"><i>out</i></span>.<span style="color: #783f04;"><b>println</b></span>(<i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;">nextInt</span>(<span style="color: #3d85c6;">9</span>) + <span style="color: #3d85c6;">7</span>] + <span style="color: red;">"\n\n"</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: #274e13; color: white; white-space: pre;">There is a 7 to add to the value returned from the "nextInt" method because it is to make sure that if the computer decides to go first, then no matter what message is displayed from this array, it's always a message saying that the computer makes its move first.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">computersChoice</span> = <b><span style="color: #783f04;">computerMakesMove</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: #783f04;">pauseProgram</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">playersChoice</span> = <span style="color: #783f04;"><b>playerMakesMove</b></span>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: purple;"><i>aiObject</i></span>.<span style="color: #783f04;">nextInt</span>(<span style="color: #3d85c6;">7</span>)] + <span style="color: red;">"\n\n"</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: #783f04;">pauseProgram</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">playersChoice</span> = <b><span style="color: #783f04;">playerMakesMove</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"Please wait as the computer decides.\n"</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">computersChoice</span> = <b><span style="color: #783f04;">computerMakesMove</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #783f04;"><b>pauseProgram</b></span>();</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Technically, the value is returned from the method computerMakesMove and assigned to computersChoice right away; the call for the pauseProgram method is simply there to let the user think that the CPU is deciding its move.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Process Phase</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">Whatever the way on who is first, once the decisions are set, the program goes through a case-by-case decision structure to determine the proper message to be displayed on output based on the player's movements. "nextInt" is a method that returns a random value from 0 to 5 exclusively, and thus it is used in sum with a constant to get a winning, losing, or tie message. If the player is winning or losing, an associated message comes with it to display as well, giving out one of the rules of the game.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">There are two sets of decision structures, along with an "else" at the very end to deduce that no one has won the game.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">The first set of if-else-if clauses are for the player's chance of winning.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: #274e13; color: white; white-space: pre;">The program uses the equals operator and the logical AND operator to determine what were the moves chosen in the game by comparing the chosen values with the constants corresponding to the rules of the game.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// Player's Streak</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Scissors cuts paper</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">32</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Paper covers rock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">33</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Rock crushes lizard</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">34</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Lizard poisons Spock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">35</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Spock smashes scissors</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">36</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Scissors decapitates lizard</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">37</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Lizard eats paper</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">38</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Paper disproves Spock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: purple;"><i>aiObject</i></span>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">39</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b><span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Spock vaporizes rock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">40</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i>)</div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Rock crushes scissors</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: purple;"><i>aiObject</i></span>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">16</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">41</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">The next set of if-else-if clauses are for the computer's chance of winning.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// CPU Streak</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Scissors cuts paper</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">32</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Paper covers rock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">33</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Rock crushes lizard</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: purple;"><i>aiObject</i></span>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">34</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i>)<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Lizard poisons Spock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">35</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Spock smashes scissors</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">36</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Scissors decapitates lizard</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">37</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i>) </div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Lizard eats paper</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">38</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_PAPER</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Paper disproves Spock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: purple;"><i>aiObject</i></span>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<span style="color: #3d85c6;">39</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i>) <span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Spock vaporizes rock</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">40</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: #666666;">playersChoice</span> == <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i> && <span style="color: #666666;">computersChoice</span> == <i><span style="color: purple;">CHOICE_IS_ROCK</span></i>)</div>
<div class="separator" style="clear: both;">
<span style="color: #38761d;"> // Rock crushes scissors</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>) + <span style="color: #3d85c6;">21</span>] + <span style="color: purple;"><i>CONSTANT_MESSAGES</i></span>[<span style="color: #3d85c6;">41</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// No winner</span><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">If there are no winners at all, the last if-else-if clause is executed.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">messageString</span> = <i><span style="color: purple;">CONSTANT_MESSAGES</span></i>[<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">6</span>) + <span style="color: #3d85c6;">26</span>];</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: orange;">/*</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Output Phase</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> */</span></div>
<div class="separator" style="clear: both;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<span style="color: purple;"><i>out</i></span>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: lime;">messageString</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;">When the proper message is assigned to the corresponding reference variable "messageString," it is displayed to tell the user who has won the game, or that the game was a draw.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: #783f04;">pauseProgram</span></b>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">playAgain</span> = <b><span style="color: #783f04;">playGameAgain</span></b>();</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">After another two-second pause, the user is asked whether to play the game again. If he does, we run the same algorithm starting after the left brace of this post-test loop, known as a do-while loop, where the inside of that loop is executed at least once. If not, the loop ceases to have another iteration executed and thus we move on to closing the program.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <b><span style="color: blue;">while</span></b>(<span style="color: #666666;">playAgain</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #38761d;">// Closing Phase</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nThank you for playing!"</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><i><span style="color: purple;">keyboardInput</span></i>.<span style="color: #783f04;"><b>close</b></span>();</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">Before the program is terminated, we close the input.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static void</span></b> <b><span style="color: #783f04;">pauseProgram</span></b>()</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">try</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">Thread</span>.<b><span style="color: #783f04;">sleep</span></b>(<span style="color: #3d85c6;">2000</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #f3f3f3;"><span style="background-color: black;">A computerized task is simply a list of instructions that is assigned to a CPU to execute. A thread holds this task awaiting for a timely execution along the CPU. You can run any number of threads in a program you write to do, let's say, some sorting by chunks, known as multithreading, because you create multiple tasks that the CPU can execute at the same time.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #f3f3f3;"><span style="background-color: black;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #f3f3f3;"><span style="background-color: black;">You have several thread management options at your disposal. In this case, we're making the thread running this program to pause for 2 seconds, or 2000 milliseconds. This method is called in a block that is actually there to watch out for any potential errors that can occur when it is called. Such errors in programming that are thrown by data entries are called exceptions.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #f3f3f3;"><span style="background-color: black;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #f3f3f3;"><span style="background-color: black;">This block makes an attempt to call the method, and "catch" any potential error this method can throw.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">catch</span></b> (<span style="color: #b45f06;">InterruptedException</span> <span style="color: lime;">ex</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">"InterruptedException" is a JAVA-based error class that an object is created and thus "thrown" into the executing code when the only thread running in this program is called to sleep, but is currently sleeping, or has its task completed.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">ex</span>.<span style="color: #783f04;"><b>printStackTrace</b></span>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #b45f06;">System</span>.<b><span style="color: #783f04;">exit</span></b>(<span style="color: #3d85c6;">1</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">Passing on the value "1" as an argument of the static method exit denotes that the program is to be terminated based on abnormal status.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">Anytime the program encounters an error while executing the method to sleep for two seconds, what happens is, as soon as this method catches it, a method is called to display details on what is the error, where did it come from, and what line is it fired from the corresponding source code. In addition, the JVM executes a method for which the program it's currently running is forced to be terminated.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static byte</span></b> <b><span style="color: #783f04;">playerMakesMove</span></b>()</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">This is where you type in your move.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">String</span> <span style="color: lime;">inputString</span>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">boolean</span></b> <span style="color: #666666;">entryIsValid</span> = <b><span style="color: blue;">true</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">do</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>print</b></span>(<span style="color: red;">"\n\n\nEnter a number corresponding to your move:\n\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"0: Rock\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"1: Paper\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"2: Scissors\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"3: Lizard\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"4: Spock\n\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"Your entry: "</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">inputString</span> = <span style="color: purple;"><i>keyboardInput</i></span>.<span style="color: #783f04;"><b>nextLine</b></span>();</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">The "nextLine" method takes input directly from the console, whether it is the computer terminal, such as Command Prompt on Microsoft Windows, or the white text area of integrated development environments that are named "Console." On Eclipse IDE, it has a tab to denote which element is which opened aside from the source code alone.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">This is where you type in an index corresponding to one of the five different movements in the game.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (!<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">""</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>length</b></span>() > <span style="color: #3d85c6;">1</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<span style="color: purple;"><i>out</i></span>.println(<span style="color: red;">"\nInput error: Too long. Please enter only one character."</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">Because the input used in this program is not really limited in terms of how long it can be, if it's more than one character, you'll have to type it in again, because the entire input is considered for this method to return an index corresponding to your move later on.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">entryIsValid</span> = <b><span style="color: blue;">true</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>charAt</b></span>(<span style="color: #3d85c6;">0</span>) < <span style="color: #3d85c6;">48</span> || inputString.<span style="color: #783f04;"><b>charAt</b></span>(<span style="color: #3d85c6;">0</span>) > <span style="color: #3d85c6;">52</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">entryIsValid</span> = <b><span style="color: blue;">false</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput error: Does not correspond to the choices given. Please "</span></div>
<div class="separator" style="clear: both;">
<span style="color: red;"> </span>+<span style="color: red;"> "enter a value corresponding to one of them."</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">If your input is not one of the five indexes, being a number from 0 to 4 inclusively, you get this message and thus you have to type in your input again.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput error: No input. Please enter again."</span>);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">You can't make a move without typing in a character; as such, this message appears.</span></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <b><span style="color: blue;">while</span></b>(<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">""</span>) || <span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>length</b></span>() > <span style="color: #3d85c6;">1</span> || !entryIsValid);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<span style="color: purple;"><i>out</i></span>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput accepted.\n\n"</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="background-color: black; color: white; white-space: pre;">A case-by-case decision structure causes this method to return a value representing a move accordingly.</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">"0"</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> <i><span style="color: purple;">CHOICE_IS_ROCK</span></i>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">"1"</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> <i><span style="color: purple;">CHOICE_IS_PAPER</span></i>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">"2"</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> <i><span style="color: purple;">CHOICE_IS_SCISSORS</span></i>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">"3"</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> <i><span style="color: purple;">CHOICE_IS_LIZARD</span></i>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> <i><span style="color: purple;">CHOICE_IS_SPOCK</span></i>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static byte</span></b> <span style="color: #783f04;"><b>computerMakesMove</b></span>()</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return</span></b> (<b><span style="color: blue;">byte</span></b>)(<i><span style="color: purple;">aiObject</span></i>.<span style="color: #783f04;"><b>nextInt</b></span>(<span style="color: #3d85c6;">5</span>));</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: #274e13;">There is a cast to downside the amount of space a value takes up in the RAM, because there are only five different moves. There is no method in the Random class that returns a signed byte (a number with eight binary digits that holds values in the range of -128 - 127). As such, we call nextInt, given a specified range where 4 is the maximum, where the method returns a signed four-byte integer (within the range of -[2^31] to 2^31-1), and then take the first eight binary digits to be assigned as a byte.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">All this method does is, it returns a random index that represents one of the five movements the player or the CPU can make.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">public static boolean</span></b> <span style="color: #783f04;"><b>playGameAgain</b></span>()</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">This is where the program asks you to whether or not you want to play the game again.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">String</span> <span style="color: lime;">inputString</span>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">boolean</span></b> <span style="color: #666666;">inputIsGood</span> = <b><span style="color: blue;">true</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">do</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>print</b></span>(<span style="color: red;">"\n\n\nWould you like to play the game again?\n\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"Please enter a character corresponding to one of the choices:\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"0: Yes\n"</span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ <span style="color: red;">"1: No\n\nYour entry: "</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: lime;">inputString</span> = <i><span style="color: purple;">keyboardInput</span></i>.<span style="color: #783f04;"><b>nextLine</b></span>();</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;">Just like the input for making your move, you'll have to type your input again if there is more than one character, there is nothing in the input, or if the character is invalid.</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><br /></span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">""</span>))</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput error: No input. Please enter again."</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">inputIsGood</span> = <b><span style="color: blue;">true</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>length</b></span>() > <span style="color: #3d85c6;">1</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput error: Too long. Please enter only one character."</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>charAt</b></span>(<span style="color: #3d85c6;">0</span>) != <span style="color: #c27ba0;">'0'</span> && inputString.<span style="color: #783f04;"><b>charAt</b></span>(<span style="color: #3d85c6;">0</span>) != <span style="color: #c27ba0;">'1'</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #bf9000;">System</span>.<i><span style="color: purple;">out</span></i>.<span style="color: #783f04;"><b>println</b></span>(<span style="color: red;">"\nInput error: Does not correspond to the choices given. Please enter a "</span></div>
<div class="separator" style="clear: both;">
<span style="color: red;"> </span>+ <span style="color: red;">"value corresponding to one of them."</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #666666;">inputIsGood</span> = <b><span style="color: blue;">false</span></b>;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} </div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <b><span style="color: blue;">while</span></b>(<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>equals</b></span>(<span style="color: red;">""</span>) || <span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>length</b></span>() > <span style="color: #3d85c6;">1</span> || !<span style="color: #666666;">inputIsGood</span>);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">if</span></b> (<span style="color: lime;">inputString</span>.<span style="color: #783f04;"><b>charAt</b></span>(<span style="color: #3d85c6;">0</span>) == <span style="color: #c27ba0;">'0'</span>)</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return true</span></b>;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">Using the input for "yes" will cause the main loop of this program to repeat again, allowing you to play the game once more.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">else</span></b></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><b><span style="color: blue;">return false</span></b>;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: white;"><span style="background-color: black;">If you decide not to play the game once again, the main loop does not repeat; instead, the last message of the program is displayed, the input is closed, and thus the program is terminated.</span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
}</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
<br />
I think that will do for this blog. This one took me a lot of time to put together; it took me over eight hours in a two-day period to work on this! But I'm pretty sure this is some first experience in learning what a Rock Paper Scissors Lizard Spock JAVA implementation would be like, although it does differ from program to program!<br />
<br />
Anyway, have a wonderful night, and I'll talk to you later!<br />
<br />
<br />
<br />
<b>Please read up my blog on my volunteering! <a href="http://gregorypdesrosiersmontreal.blogspot.ca/2015/08/my-mission-to-volunteer-for-reaching-my.html">http://gregorypdesrosiersmontreal.blogspot.ca/2015/08/my-mission-to-volunteer-for-reaching-my.html</a></b><br />
<br />
<br />
<div style="text-align: center;">
<strong>Please follow my blogger by going to the top of this page, and click on "Join this site," big blue button with the Google logo!</strong></div>
<div style="text-align: center;">
<br /><strong></strong></div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<div style="text-align: center;">
<span style="font-family: "Trebuchet MS",sans-serif; font-size: x-small;"> Click here to follow me on Facebook: </span><span style="color: #0000ee; font-family: Trebuchet MS, sans-serif; font-size: x-small;"><u>https://www.facebook.com/gregorypdesrosiersuwaterloose</u></span></div>
<div style="text-align: center;">
<span style="font-family: "Trebuchet MS",sans-serif; font-size: x-small;"> Please follow me on Twitter: <a href="https://twitter.com/GregoryDes">https://twitter.com/GregoryDes</a></span></div>
<div style="text-align: center;">
<span style="font-family: "Trebuchet MS",sans-serif; font-size: x-small;">You can also follow me on Instagram! @gregpdesig</span></div>
</form>
Gregory Desrosiershttp://www.blogger.com/profile/00189273846619965757noreply@blogger.com0tag:blogger.com,1999:blog-3222795693289545532.post-90427963345677285062013-01-12T17:58:00.006-05:002020-11-16T21:06:47.388-05:00Elementary School Graduation Message (from Principal)Hello, people.<br />
<br />I want to present to you a very touchy note written and presented by my old elementary school principal upon my graduation, Trudy Williams. It was presented on June 15, 2006.<br />
<br />
Enjoy reading this touchy message!<br />
<br />
<span face=""Trebuchet MS",sans-serif">Dear Graduates,</span><br />
<span face=""Trebuchet MS",sans-serif"><br /></span>
<span style="background-color: black;"><span face=""Trebuchet MS",sans-serif" style="font-size: x-large;">"<span style="color: red;">T</span><span style="color: orange;">r</span><span style="color: yellow;">u</span><span style="color: #f1c232;">e</span> <span style="color: lime;">C</span><span style="color: #38761d;">o</span><span style="color: cyan;">l</span><span style="color: blue;">o</span><span style="color: purple;">r</span><span style="color: magenta;">s</span>" </span></span><br />
<span face=""Trebuchet MS",sans-serif">is the 2006 graduation theme at Boucherville Elementary SChool, your graduation theme. Over the year, you did show your true colours, each and every one of you.</span><br />
<span face=""Trebuchet MS",sans-serif"><br /></span>
<span face=""Trebuchet MS",sans-serif">You showed your true colors from the very first day that I met you in January. I saw evidence of good strong friendships being developed that I am positive will continue to grow for many years to come. You showed your true colors when you participated in the reading week activities in February. You demonstrated responsibility and wore a huge smile as you read with your younger reading buddies. You showed your true colors as you operated the telephone lines at lunchtime. Your professional manner was noticed by numerous callers who complemented me on your professionalism. And once again, you showed your true colors when you helped Mr. Sylvain (Lemarre, a Phys. Ed. teacher) organize and run the events at the Spring Fling. You demonstrated great leadership qualities as you explained each activity and guided the younger students through each event, step by step. You showed your true colors in many of our in-house competitions such as the Boucherville Public Speaking Contest, The Can-Spell Contest, and The Mad Minute Math Contest. Stomach butterflies surfaced and adrenaline soared as you demonstrated great academic skills at these events and many others throughout the year. You also showed your true colors in front of the camera as you proudly presented your work when we created the film with Heritage Regional High School and when you made commercials with Madame Valerie (Ducharme, a French teacher). Your true colors were more than just black and white. The color pink surfaced as hot pink as you performed the Pink Panther Dance for all Boucherville Elementary students to enjoy. The audience was in awe. You showed your true colors, true multi colors to be more precise, as you participated in the Arts Smarts Project, "Making a Difference." The beautiful ceramic mosaic table will indeed be a colorful mark left by you, the graduating class of 2006. You showed your true colors during the SSIAA (<span class="st">South Shore Interscholastic Athletics Association) soccer tournament. Yes, the Boucherville red and white is a winning combination.</span></span><br />
<span face=""Trebuchet MS",sans-serif"><span class="st"><br /></span></span>
<span face=""Trebuchet MS",sans-serif"><span class="st">As you leave your "Boucherville Elementary School Family," always remember to show your true colors, be true to yourself, make good decisions, and be a life long learner. Keep the wonderful colorful memories of Boucherville Elementary School alive in your heart and treasure them forever.</span></span><br />
<span face=""Trebuchet MS",sans-serif"><span class="st"><br /></span></span>
<span face=""Trebuchet MS",sans-serif"><span class="st">You're beautiful! Your true colors are beautiful!</span></span><br />
<span face=""Trebuchet MS",sans-serif"><span class="st">Congratulations, class of 2006!</span></span><br />
<span face=""Trebuchet MS",sans-serif"><span class="st"><br /></span></span>
<span face=""Trebuchet MS",sans-serif"><span class="st">Mrs. Williams, Principal</span></span><br />
<span class="st"><br /></span>
<span class="st">The song "True Colors" was written by </span><a href="http://en.wikipedia.org/wiki/Billy_Steinberg" title="Billy Steinberg">Billy Steinberg</a> and<a href="http://en.wikipedia.org/wiki/Tom_Kelly_%28musician%29"> Tom Kelly</a>. The original song was actually performed by Cyndi Lauper (now at 59 years old), and was released in her second album, also called True Colors, on July 25, 1986. It reached #1 of the US Billboard Hot 100 of 1986, but it only stood at the top for two weeks.<br />
<br />
You can listen to the song here: http://www.youtube.com/watch?v=LPn0KFlbqX8<br />
This is the original music video produced in the same year it was recorded by Sony BMG Music Entertainment.<br /><b><br /></b>Gregory Desrosiershttp://www.blogger.com/profile/00189273846619965757noreply@blogger.com0