TAILIEUCHUNG - PHP 5/MySQL Programming- P30

PHP 5/MySQL Programming- P30:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | td tr table HERE Because the form specifies no action PHP defaults to the same page that contains the form. Programs that repeatedly call themselves benefit from this option. Creating the evaluate Function The evaluated function s purpose is to examine the die array and see if the user has achieved patterns worthy of reward. Again I print the entire function here and show some highlights after. function evaluate global die cash set up payoff payoff 0 subtract some money for this roll cash - 2 count the dice numVals array 6 for theVal 1 theVal 6 theVal for dieNum 0 dieNum 5 dieNum if die dieNum theVal numVals theVal end if end dieNum for loop end theVal for loop print out results for i 1 i 6 i print i numVals i br n end for loop count how many pairs threes fours fives numPairs 0 numThrees 0 Chapter 4 Loops and Arrays 124 PHP 5 MySQL Programming for the Absolute Beginner numFours 0 numFives 0 for i 1 i 6 i switch numVals i case 2 numPairs break case 3 numThrees break case 4 numFours break case 5 numFives break end switch end for loop check for two pairs if numPairs 2 print You have two pairs br n payoff 1 end if check for three of a kind and full house if numThrees 1 if numPairs 1 three of a kind and a pair is a full house print You have a full house br n payoff 5 else print You have three of a kind br n payoff 2 end pair if end three if check for four of a kind if numFours 1 print You have four of a kind br n payoff 5 end if check for five of a kind if numFives 1 print You got five of a kind br n payoff 10 end if check for flushes if numVals 1 1 numVals 2 1 numVals 3 1 numVals 4 1 numVals 5 1 print You have a flush br n payoff 10 end if Chapter 4 Loops and Arrays if numVals 2 1 numVals 3 1 numVals 4 1 numVals 5 1 numVals 6 1 print You have a flush br n payoff 10 end if print You bet 2 br n print Payoff is payoff br n cash payoff end evaluate The evaluate function s general strategy is to subtract 2 for the player s bet each time. Change this to make the game easier

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.