PHP 5/MySQL Programming- P39

PHP 5/MySQL Programming- P39: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 | 168 PHP 5 MySQL Programming for the Absolute Beginner print failed to place word counter keepGoing FALSE itWorked FALSE end if counter if counter count word keepGoing FALSE end if end while return itWorked end fillBoard The function begins by defining an array for directions. At this point I decided only to support placing words in the four cardinal directions although it would be easy enough to add diagonals. Hey that sounds like a dandy end-of-chapter exercise The direction array holds the initials of the four directions I have decided to support at this time. The itWorked variable is a Boolean which reports whether the board has been successfully filled. It is initialized to TRUE. If the addWord function fails to place a word the itWorked value is changed to FALSE. The counter variable counts which word I m currently trying to place. I increment the value of counter each time through the loop. When counter is larger than the word array the function has successfully added every word and can exit triumphantly. To choose a direction I simply created a random value between 0 and 3 and referred to the associated value of the direction array. The last line of the function returns the value of itWorked. The fillBoard function is called by the main program until it succeeds. This success or failure is reported to the main program by returning the value of itWorked. Adding a Word The fillBoard function handles the global process of adding the word list to the game board but addWord adds each word to the board. This function expects two parameters the word and a direction. The function cleans up the word and renders slightly different service based on which direction the word is placed. It places each letter of the word in an appropriate cell while preventing it from being placed outside the game board s boundary. It also checks to make sure that the cell does not currently house some 169 other letter from another word unless that letter happens to be the one the function

Không thể tạo bản xem trước, hãy bấm tải xuống
20    17    1    21-03-2023
51    18    1    21-03-2023
176    192    1    21-03-2023
Đã 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.