TAILIEUCHUNG - PHP 5/MySQL Programming- P29

PHP 5/MySQL Programming- P29: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 | 118 PHP 5 MySQL Programming for the Absolute Beginner html head title poker dice title style type text css body background green color tan style head body center h1 Poker Dice h1 form Building the Main Code Body The Poker Dice program is long enough to merit functions. I broke it into smaller segments here but you may want to look at its entirety which is on the CD that accompanies this book. The main part of the code sets up the general program flow. Most of the work is done in other functions called from this main area. check to see if this is first time here if empty cash cash 100 end if rollDice if secondRoll TRUE print h2 Second roll h2 n secondRoll FALSE evaluate else print h2 First roll h2 n secondRoll TRUE end if printStuff The first order of business See if this is the first time the user has come to this page. It s important to understand how timing works in this program. The user thinks he is playing the same game for several turns but the entire program runs again each time he rolls the dice. The program has different behavior based on which form elements if any have values. If the user has never been to the page before the value for the cash variable is null. The first if statement checks this condition. If the cash variable has not yet been created the user gets a starting value of 100. I wish real casinos worked like this. The program then calls the rollDice function which is described momentarily. This function rolls the dice and prints them to the screen. If you look carefully at the program as it is running you see it runs in two different modes. Each turn consists of two possible rolls. On the first roll the user is given the ability to save a roll with a checkbox. No scoring is performed. The second roll has no checkboxes because the user needs to start with all fresh dice on the next turn . The program tracks the player s score by adding money for various combinations. The secondRoll variable keeps track of whether the user is on the second .

TÀI LIỆU MỚI ĐĂNG
10    178    3    24-12-2024
28    158    1    24-12-2024
13    158    1    24-12-2024
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.