- 1、本文档共101页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
2.2 Fundamentals of Object-Oriented Programming Designing Classes Transforming English Specification into Java Lifecycle of Objects The HtmlPage Class Using Class Documentation The AlgaeColony Class Readings 参考书 1.3节 3.1节和3.2节 4.2,4.3,4.4,4.6,4.7和4.8节 第四章的“Java Interlude: Declarations, Access, and Objects” (P150-153) 2.2.6 The AlgaeColony Class 设计AlgaeColony类 描述AlgaeColony类的spcification 将规范(specification)编码实现 Designing the AlgaeColony Class The simulation program generates random amounts of sunlight per cell, a portion of which is converted to life energy by the AlgaeColony. The energy of any organism at any given time must be between the minimum amount needed to stay alive and the maximum amount of energy that it can carry. If the energy carried by the organism falls below the minimum, it will die. An AlgaeColony that is dead disappears from the lake. An AlgaeColony that is alive changes color based on the level of energy it carries. Designing the AlgaeColony Class When an AlgaeColony is eaten by a Catfish, it must give up some energy. All organisms expend some energy to live. Every organism belongs to a certain species of living beings. a certain age measured in terms of blocks of time. One block of time is equivalent to one step of simulation. Designing the AlgaeColony Class Simulation程序为每个格子随机的生成水草生存需要的阳光,其中一部分阳光被水草吸收转为能量 任何生物的能量值有个最小值,低于该最小值该生物就死了,也有一个最大值,即该生物可携带的最高能量。 如果水草死了,它就从simulation中消失了。 水草的颜色随着其能量值的变化而变化. 当水草被鱼吃了,其能量值减少. 水草生存需要能量. 每个生物都属于一定的物种. 每个生物在一个时间段内具有一定的年龄。 Summary Designing Classes Transforming English Specification into Java Lifecycle of Objects The HtmlPage Class Using Class Documentation The AlgaeColony Class Referencing Objects BankAccount account1; BankAccount account2; account1 = new BankAccount(Achebe); account2 = new BankAccount(Bob); New BankAccount(“Achebe”)语句建立一个新的对象,并返回对新建BankAccount对象的引用; account1是一个变量,account1=new BankAccoutn(“Achebe”)语句将new返回的BankAccount对象的引用赋值给account account1变量是对新建的BankAcc
文档评论(0)