Writing real code

设计程序的步骤

  1. First, a high-level design and a flowchart
  2. more details
  3. Working through the Psedocode:作者将 psedocode 分为了两个部分,分别是 variables 和 logic ,它们的作用分别是

The variables will tell us what we need to keep track of in our code, and the logic describes what the code has to faithfully implement to create the game.(And using indentation to help make the psedocode easier to read.)

认识 boolean operators

boolean opetators 有两种:comparison operators 和 logical operators.

  • Comparison Operators compare two values
  • Logical Operatore combine two boolean expessions to create one boolean result

一些 JavaScript 的 bultin-functions

alert("content")

用于显示一个含有 content 的 dialogue box.

prompt("prompt")

作用:和 alert 特别像,另外还有一个可供 User 输入的输入框,User 在里面的输入值称为这个函数的返回值。这个输入值的类型是 string 类型的。
注意:在这里和 C 语言有一点不同的是:当你输入一个数字的时候,返回的时候是一个字符,但是如果写成和另外一个数字比较的形式,JavaScript 会自动将这个字符串转换为数字。

Math.random()

Mathrandom()没有参数,返回一个0~1的数(including 0, but not including 1),如果想要一个0~(n-1).9999的数,可以这样写:var randomLoc = Math.random()*n

Math.floor(num)

Math.floor()用于将 num round down to their nearest interger value.

最新文章

  1. OpenCV2邻域和模板操作
  2. svn-多个项目版本库和自动同步更新post-commit
  3. 四则运算的实现(C++)重做
  4. JS 打印对象的方法
  5. HDU 2846 (AC自动机+多文本匹配)
  6. CAS实现单点登入(sso)经典教程
  7. [转] - Linux网络编程 -- 网络知识介绍
  8. C++初始化列表问题
  9. delphi学习treeview中从表列名和数据添加为目录并双击自动选中
  10. couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
  11. 自己开发轻量级ORM(二)
  12. 201521123017 《Java程序设计》第10周学习总结
  13. 201521123038 《Java程序设计》 第十二周学习总结
  14. Linux stat函数和stat命令
  15. margin的垂直方向塌陷
  16. ionic3.x版本开发问题记录---使用Image Resizer打包报错问题
  17. 转载:深入理解Scala的隐式转换系统
  18. Error: php71w-common conflicts with php-common-5.4.16-46.el7.x86_64
  19. Photoshop 辅助线和标尺的使用技巧
  20. Angular入门笔记

热门文章

  1. docker 给运行的容器映射本地端口
  2. POJ 1679 The Unique MST 【判断最小生成树是否唯一】
  3. Manjaro 安装与配置
  4. Minikube 安装
  5. 外键 Foreign keys
  6. LuoguP3792 由乃与大母神原型和偶像崇拜
  7. 论文阅读:Learning Visual Question Answering by Bootstrapping Hard Attention
  8. Jenkins-Linux环境搭建
  9. Java中泛型Class<T>、T与Class<?>、 Object类和Class类、 object.getClass()和Object.class
  10. JqGrid 列时间格式化