- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Compiling and Running Multiple Classes Compile HtmlPage.java file Compile HtmlWelcome.java file Javac HtmlWelcome.java HtmlPage.java Load the class file to workbench Open HtmlWelcomeForm.html in workbench and submit the form to see result. 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 The HtmlImage Class Documentation for the HtmlImage Class Using the HtmlImage Class 2.2.5 Using HtmlImage Class The HtmlImage Class Our goal is to re-write the TravelRequest servlet We are told that we can separate all HTML code generation from the servlet if we use both HtmlPage and HtmlImage classes. We re-write the source code for the TravelRequest servlet to use the HtmlPage class. HtmlPage myPage = new HtmlPage(); myPage.addText( IMG src=/ + destination + alt= + destination + ); The HtmlImage Class Documentation for the HtmlImage Class The HtmlImage class is a simple class with one constructor and one method The values for the src and alt attributes are passed as parameters to the constructor when the HtmlImage class is instantiated We can send the buildHtml message to the HtmlImage class to obtain the HTML code for the IMG tag that we can then add to our Web page. Using the HtmlImage Class First, we create an instance of the HtmlImage class HtmlImage destinationImage = new HtmlImage( / + destination, destination ); Next, we add the image to the Web page myPage.addText( destinationImage.buildHtml() ); Last, Compile the files and prepare to execute. 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 2.2.6 The AlgaeColony Class Designing the AlgaeColony Class Engl
文档评论(0)