MIT OpenCourseWare


» 进阶搜寻
 课程首页
 教学大纲
 教学时程
 课堂讲稿
 实作课程
 测验
 专题
 相关资源
 讨论群组

实作课程


本页翻译进度

灯号说明

审定:无
翻译:庄鸿国(简介并寄信)
编辑:陈盈(简介并寄信)


这部份课程需要Java® Virtual Machine software软件(自动安装在大部份的浏览器中),以执行.class文档,任何像是 JCreator®的工具都可以用来编译及执行.java的文档,而像是  Winzip® 或 StuffIt®的解压缩软件可以用来开启.zip的文档。
Java® Virtual Machine software (automatically installed in most major web browsers) is required to run the .class files in this section. Any number of development toolds, such as JCreator®, can be used to compile and run the .java files in this section. File decompression software, such as Winzip® or StuffIt®, is required to open the .zip files in this section.

这部份课程提供一系列完整的实作习题,所有的实作习题须在发下当天完成提交。
This section provides a complete set of lab assignments for this course. All labs are due on the same day they are handed out.

课程SP.772,特别在实验室习题部分需要使用免费的 JCreator®,这是功能强大的直觉式组件界接接口整合开发环境系统(IDE),所占的空间也很少(约3MB),即使本课程使用 JCreator®,还是可以利用文字编辑及指令行处理器功能完成全部的习题。
The curriculum for SP.772, specifically the laboratory assignment portion, assumes the use of a free tool called JCreator®, a powerful IDE for Java that does not occupy much disk place (approximately 3 MB). Although this curriculum uses JCreator®, it is possible to complete all of the assignments by simply using a text editor and the command prompt.

实验室习题B9-B17的解答在.zip文档中,为了正确执行编码,这些文档必须与.zip中文档格式一样。
Laboratory assignments B9-B17 have their solutions located within .zip files. In order to run the code correctly, the files must be organized in the same manner as within the .zip file.

Java® 实作
Java® Labs

课程单元 实作 解答
JAVA®
1 L1: Java®介绍
L1: Introduction to Java®
B0: Hello World (PDF) (PDF)
2 L2: 变量与数据格式
L2: Variables and Data Types

L3: 操作数
L3: Operators
B1: 变量与操作数
B1: Variables and Operators (PDF)
(PDF)
3 L4: 控制结构
L4: Control Structures
B2: 控制架构
B2: Control Structures (PDF)
(PDF)
4 L5: Array(数组)
L5: Arrays
B3: 成绩簿 1
B3: Gradebook 1 (PDF)

B3a: JCreator (PDF)
Gradebook.class (CLASS)
Gradebook.java (JAVA)
5 L6: Method(方法)
L6: Methods
B4: 成绩簿2
B4: Gradebook 2 (PDF)

Gradebook.class (CLASS)
Gradebook.java (JAVA)

辅助文档
Supporting Files

EasyReader.class (CLASS)

6 随堂考 1
Quiz 1

L7: Class(类别)与Object(物件)I
L7: Classes and Objects I
B5: 成绩簿OO 1
B5: GradebookOO 1 (PDF)

GBProgram.class (CLASS)
GBProgram.java (JAVA)
GradeBookOO.class (CLASS)
GradeBookOO.java (
JAVA)

辅助文档
Supporting Files

EasyReader.class (CLASS)

7 L8: Class(类别)与Object(物件)II
L8: Classes and Objects II
B6: 成绩簿OO 2
B6: GradebookOO 2 (PDF)

(PDF)

GBProgram.class (CLASS)
GradeBookOO.class (CLASS)
GBProgram.java (JAVA)
GradeBookOO.java (JAVA)

辅助文档
Supporting Files

EasyReader.class (CLASS)

8 L9: Lists(列表)与Iterators(迭代器)
L9: Lists and Iterators
B7: 成绩簿OO 3
B7: GradebookOO 3 (PDF)

B7: 成绩簿OO 3a
B7: GradebookOO 3a (PDF)

(PDF)

GBProgram.class (CLASS)
GradeBookOO.class (CLASS)
GBProgram.java (JAVA)
GradeBookOO.java (JAVA)

辅助文档
Supporting Files

EasyReader.class (CLASS)

9 L10: Static(静态变量)与Final(常态变量)
L10: Static and Final
B8: 赛车1
B8: Racecar 1 (PDF)

(PDF)

RaceCar.class (CLASS)
RaceCar.java (JAVA)

辅助文档
Supporting Files

EasyReader.class (CLASS)

10 测验 1
Exam 1
11 L11: Package(封装),Scope(范围)与Access(存取)
L11: Package, Scope and Access
B9: 赛车 2
B9: Racecar 2 (PDF)
(ZIP) (本 ZIP文档包含:两个.class文档和两个.java文档)
(The ZIP file contains: 2 .class files and 2 .java files.)
12 L12: Inheritance(继承)
L12: Inheritance
B10: 学生1
B10: Students 1 (PDF)
(ZIP) (本 ZIP 文档包含:六个.class文档和六个.java文档)
(The ZIP file contains: 6 .class files and 6 .java files.)
13 随堂考2
Quiz 2

L13: Abstrac(抽象)Class(类别)与Interfaces(界面)
L13: Abstract Classes and Interfaces
B11: 学生 2
B11: Students 2 (PDF)
(ZIP) (本ZIP 文档包含:七个.class文档和七个.java文档和一个.txt文档)
(The ZIP file contains: 7 .class files, 7 .java files and 1 .txt file.)
14 L14: Exceptions(例外处理)
L14: Exceptions
B12: 我的商店 1
B12: MyStore 1 (PDF)
(ZIP) (本 ZIP 文档包含:四个.class文档和四个.java文档。)
(The ZIP file contains: 4 .class files and 4 .java files.)
15 L15: IO(输出输入) 和Parsing(解析)
L15: IO and Parsing
B13: 我的商店2
B13: MyStore 2 (PDF)
(ZIP) (本 ZIP 文档包含:十四个.class文档、七个.java文档、 一个.jsp 文档和三个 .txt 文档.)
(The ZIP file contains: 14 .class files, 7 .java files, 1 .jsp file and 3 .txt files.)
16 L16: 介绍Swing
L16: Introduction to Swing
B14: 计算器1
B14: Calculator 1
(ZIP) (本ZIP 文档包含:五个.class文档和五个.java文档)
(The ZIP file contains: 5 .class files and 5 .java files.)
17 L17: Swing 事件模块
L17: Swing Event Model
B15: 计算器2
B15: Calculator 2
(ZIP) (本 ZIP 档包含:五个.class文档和五个.java文档)
(The ZIP file contains: 5 .class files and 5 .java files.)
18 随堂考 3
Quiz 3

L18: 集Collections I
L18: Collections I
B16: 扑克牌 1
B16: Card Game 1 (PDF)
(ZIP) (本ZIP文档包含:十一个.java文档、一个.class文档、一个.gif文档、 一个.list文档和三十二个 .html 文档)
(The ZIP file contains: 11 .java files, 1 .class file, 1 .gif file, 1 list file and 32 .html files.)
19 L19: 集Collections II
L19: Collections II
B17: 扑克牌2
B17: Card Game 2 (PDF)
(ZIP)(The ZIP 文档包含:十一个.java档、一个.class文档、 一个.gif文档、一个.list文档和三十二个 .html 文档)
(The ZIP file contains: 11 .java files, 1 .css file, 1 .gif file, 1 list file and 32 .html files.)


JSP™ 实作
JSP™ Labs

练习0-〈开创你的商店〉
Exercise 0 - "Start your Own Store"

在你的第一个练习里,我们会要求你设计网络商店的网页,你的商店可以用任何你想要的名字命名,且以任何价格出售任何想卖的物品,目前,你的顾客无法买任何东西,因为我们还不知道JSP™ ,但是别担心,在下一个练习中我们会提到。你的网站需要三个必要条件,第一个条件是它必须有至少三页网页,其中一个网页是主页,另两页必须可以从主页连结,你当然可以自由增加网页的数量,我们也非常鼓励同学这样做; 第二个条件是你的商店所贩卖的物品旁都会有物品的图案,第三个条件是必须有要统一的外观,整个网站的页首和页尾看起来是一样的。

For your first exercise, we ask you to build some web pages representing an online store. Your store can have any name you want and sell anything you want at any price. For now, your visitors won't be able to buy anything because we don't know JSP™ yet, but don't worry, we'll get to that in later exercises. There are three main requirements for your site. The first is that it must include at least 3 pages, one of which is a home page and at least 2 pages which are reachable from the home page. You are free to add more pages, of course, and we encourage you to do so. Second, your store must show an image alongside each item it is selling. Third, it must have a uniform look and feel with the top and bottom of every page looking the same across the entire site.

练习1-〈让你的商店更生动活泼〉
Exercise 1 - "Making Your Store Dynamic"

在这个练习中,我们继续上一个练习实作中架设的网络商店,首先,你将把所有文档的扩展名为“.html”改成“.jsp”,再来是每一页都会以容易阅读的方式显示目前的日期,不像课堂中所举的例子那样难读(提示:参考文档:java.text.DateFormat),最后你要使用最少一个JSP™ 的表示式,一个JSP™ 的宣告,一个JSP™ 服务端处理过程,和直接引入一个JSP™ 的网页到你的网站中。

In this exercise, we're going to continue with the online store you started in Exercise 0. First, you'll have to change all your files ending in ".html" into files ending in ".jsp". Next, every page should show the current date in a nice, easy-to-read format, unlike the examples in class in which the date was complicated to read (hint: take a look at the java.text.DateFormat). The last requirement is that you use at least one JSP™ expression, one JSP™ declaration, one JSP™ scriptlet, and one JSP™ page import directive in your site.

练习2-〈疯狂购物〉
Exercise 2 - "Shopping Spree"

现在你可以让顾客买你的东西了,他们应该可以点击网页上项目开始购物,这会带入一个确认画面,让他们可以输入名字及邮寄地址,实际付款方式先忽略不管,但是,这网页会提示顾客是否输入有效的姓名和住址。

Now it's time to let your visitors buy the items you have for sale. They should be able to start the purchasing process by clicking on an item. This should bring them to a confirmation screen in which they can enter their name and shipping address. We will ignore how they will actually pay for item. The site should warn you if the name or address is invalid in any way.

练习3-〈让程式模组化〉
Exercise 3 - "Making Your Code Modular"

从每个网页中找出相同的程式码,然后放至其他文档中,这些不同的文档应包含(不管是以动态或静态方式)在原本的网页中;就是在验证数据的合法性后,格式认证网页会连结到“成功”网页,否则会回到格式认证页面,这“成功的网页”就是表示购物成功。

Extract the common code from each of your pages and place it into separate files. These separate files should now be included (either statically or dynamically) from the original pages. Also, have your form validation pages forward to a "success" page if the data is valid, and back to the form otherwise. By a "success" page, we mean a page that indicates the purchase was made successfully.

练习4-〈保存购物车内的商品〉
Exercise 4 - "Keeping a Shopping Cart"

你的网络商店在功能上尚有些限制,第一,顾客每次只能买一种商品,第二,顾客每次购物时都必须输入顾客名称与住址。解决第一个问题可利用在网页的联机时间内将选购的物品保留在购物车中,如此,顾客就可以之后在“结帐柜台”一次结清,买到全部他想要买的物品,而要解决第二个问题的方法就是利用计算机的cookie档纪录使用者的姓名与住址,然后自动填到姓名/住址HTML格式中。

There are currently a few limitations to your online store. They are 1) that users have to purchase each item they want to buy individually, and 2) that they must enter in their name and contact information for every purchase. Fix problem 1 by keeping selected items in a "shopping cart" that you store in the session. The user can then later proceed to the "checkout counter" to buy all the items at once. And fix problem 2 by keeping a cookie that stores the users name and address and automatically fills the name and address HTML form with that information.

练习5-〈隆重的开幕〉
Exercise 5 - "The Grand Opening"

重新检视你的程序代码确保网页的完整呈现,为此,你必须要建立至少一个被JSP™网页呼叫的Java® 的class程式,在隆重开幕前做最后确认的动作,若一切准备就绪,就邀请其他人坐在你的计算机前开始好好地浏览你的网络商店。

Rework your code to ensure a clear separation of the presentation of the pages from the logic driving the pages. In doing so, you must create at least one Java® class that is called from JSP™ pages. Put the finishing touches on your site for the grand opening. When you're done, invite others to sit at your computer and navigate your store.


 
MIT Home
Massachusetts Institute of Technology Terms of Use Privacy