PHP 5/MySQL Programming- P31

PHP 5/MySQL Programming- P31: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 | 128 PHP 5 MySQL Programming for the Absolute Beginner check for two pairs if numPairs 2 print You have two pairs br n payoff 1 end if Of course you re welcome to change the payoffs. As it stands this game is incredibly generous but that makes it fun for the user. Looking for Three of a Kind and a Full House I combine the checks for three of a kind and full house which is three of a kind and a pair . The code first checks for three of a kind by looking at numThrees. If the user has three of a kind it then checks for a pair. If both these conditions are true it s a full house and the user is rewarded appropriately. If there isn t a pair the user gets a meager reward for the three of a kind. 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 Checking for Four of a Kind and Five of a Kind Checking for four- and five of a kind is trivial. Looking at the appropriate variables is the only necessity. 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 Checking for Straights Straights are a little trickier because two are possible. The player could have the values 1-5 or 2-6. To check these situations I used two compound conditions. A compound condition is made of a number of ordinary conditions combined with special logical operators. Look at the straight-checking code to see an example check for straights if numVals 1 1 numVals 2 1 numVals 3 1 numVals 4 1 numVals 5 1 print You have a straight 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 straight br n payoff 10 Notice how each if statement has a condition made of several subconditions joined by the operator The operator is called a Boolean

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.