Some help me with my Final Exam in HTML?

GROVE

New member
I need Someone can Find out For shuffle deck and deal 5 cards?

<head>
<title>Poker Game</title>

<STYLE type='text/css'>
p { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px; color: #000000; }

div.card { background-color: #FFF; width: 72px; height: 100px;
outline: 2px solid black; position: relative; float: left;
border: solid 2px white; margin: 4px; }

input { background-color: #FA0; }

div.buttons { background-color: #FFF; width: 600px; height: 28px;
position: absolute; left:10px; top:200px;}

</STYLE>

<script type='text/javascript' src='lib.js'>
</script>
<script type='text/javascript' src='poker.js'>
</script>
<script type='text/javascript'>
// create some global variables
var deck = new Array();
var top_card = 0;
var initDeck = false;
</script>

</head>
<body>

<div id='player' class='playerArea'>
<h3>Let's Play Poker</h3>
<div class='card' id='card_area'>
<img alt="card one" name="card1_img"
onclick='exchange(); return false;'>
</div>

</div>


<div class="buttons">

<input type=button value='get a deck'
onclick=' init(deck);
initDeck = true;
top_card = 0;
document.card1_img.src = deck[52].src;
return false;
'>

<input type=button value='check cards'
onclick='if ( !initDeck )
init(deck);
if (top_card == 51)
top_card = 0;
else {
top_card++;
document.card1_img.src = deck[top_card].src;
}
return false;
'>
<input type=button value='shuffle deck'
onclick='if ( !initDeck )
init(deck);
// you have to write the shuffle function
shuffle(deck);
return false;
'>
<input type=button value='deal 5 cards'
onclick='if ( !initDeck )
init(deck);
// you have to write the deal hand function

deal(deck);
return false;
'>

</div>

</body>

</html>

1 day ago
- 3 days left to answer.

Additional Details
______________________________________...
poker.js

// shuffle deck d *FINISH*
function shuffle ( d )
{
var i = Math.floor((Math.random() * 52) + 1);
var j = Math.floor((Math.random() * 52) + 1);

alert("you need to code this");
}

// deal 5 cards from deck d *FINISH*
function deal ( d )
{

alert("you need to code this");
}

// initialize deck d with 54 card images - should call this ONCE only
function init ( d )
{
var img_fname;
var num;

// load the deck with 54 card images - the last two are jokers
for (var i = 0; i < 53; i++)
{
num = i + 1;
img_fname="http://www.cs.csub.edu/~der...
d = new Image();
d.src = img_fname;
}

}

// swap card i with card j in deck d
function swapCard(d,i,j)
{
var tmpimg = new Image();
tmpimg.src = d.src;
d.src = d[j].src;
d[j].src = tmpimg.src;
}

1 day ago
__________________________________


// javascript utility functions

// write data surrounded by tag to the document as the page is loaded
function output(data, tag)
{
document.write("<" + tag + ">" + data + "</" + tag + ">");
}

// change the source of image i to filename
function changeImg(i, filename)
{
show(i);
i.src=filename;
}

// make element e invisible
function hide(e)
{
e.style.visibility = 'hidden';
}


// make element e visible
function show(e)
{
e.style.visibility = 'visible';
}

// write text to element e
function changeTxt(area, text)
{
e=document.getElementById(area);
e.innerHTML = text;
}
 
Back
Top