Hello

Welcome to my page!

Javascript

 
Links

Code

 

<form name="game">

<input type="radio" name="game" value="rock" checked><STRONG>Rock</STRONG><BR>
<input type="radio" name="game" value="paper"><STRONG>Paper</STRONG><BR>
<input type="radio" name="game" value="scissors"><STRONG>Scissors</STRONG>

<INPUT type="button" name="play" value="Play" onClick="shakeIt();">

<script>

//Julio Maravilla Oct. 5
function shakeIt()
{var roll;
var play;
roll=Math.floor(Math.random()*3)+1;
switch(roll)
{case 1:
play="rock";
break;

case 2:
play="paper";

break;

case 3:
play="scissors"
break;
}
if (document.game.game[0].checked) var player = "rock";
if (document.game.game[1].checked) var player = "paper";
if (document.game.game[2].checked) var player = "scissors";

if(play==player)
{
alert("Its a tie, you picked a "+player+ " and I picked a " + play +". Good way of not losing.");
}
else
{
if(player=="rock")
{
if(play=="paper")
{
alert("Sorry, you lost. I played paper, while you played rock, better luck next time");
}
else
{
alert("Congratulations!!! You played rock, while I played scissors.");
}
}

if(player=="paper")
{
if(play=="scissors")
{
alert("Sorry, you lost. I played scissors, while you played paper, better luck next time");
}
else
{
alert("Congratulations!!! You played paper, while I played rock.");
}
}

if(player=="scissors")
{
if(play=="rock")
{
alert("Sorry, you lost. I played rock, while you played scissors, better luck next time");
}
else
{
alert("Congratulations!!! You played rock, while I played scissors.");
}
}

}
}

</script>

 

 

 

Links

Contact me

Favorite links

Computer Science

Five Classmates