设为首页 加入收藏

TOP

4.8.1 游戏规划
2013-10-07 14:45:29 来源: 作者: 【 】 浏览:50
Tags:4.8.1 游戏 规划

4.8.1  游戏规划

在用C++(www.cppentry.com)写代码之前,用伪代码对该游戏程序进行规划。

  1. Create a group of words  
  2. Pick a random word from the group as the secret word  
  3. While player hasn’t made too many incorrect guesses and hasn’t guessed the secret  
  4. word  
  5. Tell player how many incorrect guesses he or she has left  
  6. Show player the letters he or she has guessed  
  7. Show player how much of the secret word he or she has guessed  
  8. Get player’s next guess  
  9. While player has entered a letter that he or she has already guessed  
  10. Get player’s guess  
  11. Add the new guess to the group of used letters  
  12. If the guess is in the secret word  
  13. Tell the player the guess is correct  
  14. Update the word guessed so far with the new letter  
  15. Otherwise  
  16. Tell the player the guess is incorrect  
  17. Increment the number of incorrect guesses the player has made  
  18. If the player has made too many incorrect guesses  
  19. Tell the player that he or she has been hanged  
  20. Otherwise  
  21. Congratulate the player on guessing the secret word  

尽管伪代码没有说明要编写的每一行代码,但它很好地描述了需要做的工作。接下来我们开始编写程序。
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇4.8.2 创建程序 下一篇4.8 Hangman简介

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: