星期五, 10月 05, 2007

10-5-2007 點名未到

電子三乙 郭逸興
電子三乙 李文森
電子三丙 謝志揚
電子三丙 潘冠宇
電子三甲 鄭安舜
電子四乙 黃璽祐 (有請假單)
電子四乙 林士傑 (有請假單)
電子四甲 曾韋碩
醫工四甲 東峻平

下次務必帶課本

同桌兩人可共用一本,新版或舊版不拘,下次未帶者,將開始抵扣平常分數,每次十分至零分為止。

Lab: Keyborad Input

Rewrite Display 2.6 using BufferedReader.

You need to import the following packages in the first place.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Change

Scanner keyboard= new Scanner(System.in);

into

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

String inputString = keyboard.readLine();

Note the Main method needs IOException handling as follows:

public static void main (String[] args) throws IOException

Lab: Scanner

Do Display 2.6.

Lab: Adding Links on Your Blog

1. Check into your blog homepage.
2. Enter "自訂"
3. Select "連結清單"
4. Write down "http://javaatcycu.blogspot.com/" and the title as "Java物件導向程式設計"
5. Also add your own favorite links.

Programming Styles

Goal:
Make your code easy to read and easy to modify.

Spelling conventions
  • name the variables as the names suggest
  • Start the name of classes with uppercase letters (such as String, FirstProgram) and start the names of variables, objects, and methods with lowercase letters.
  • Word boundaries are indicated by an uppercase letter, as in numberOfPods
  • Java spells things out in full. Use BufferedReader instead of BufReader, BuffReader, BufferedR or BR. With abbreviations, we often cannot recall how the identifier is abbreviated.
Comments
  • "Just enough" is enough.
  • When something is important and not obvious, it merits a comment.
  • Example of unnecessary comment
interest = balance * rate; //Computes the interest.

Self-documenting
  • the structure of the program is clear from the choice of identifier names and indenting pattern.
Indenting
  • The general rule of indenting is easy. When one structure is nested inside another structure, the inside structure is indented one more level.
  • We prefer to use four spaces for each level of indenting. Indenting only two or three spaces is fine so long as you are consistent. One space is not enough to be clearly visible.

Oct-12-2007 Quiz of Chap. 1

Format: Open book, computer-based test
Running time: 30 min.
Scope: Chap. 1