好好學習.天天向上

嶺南大學社區學院 資訊科技、數學及科學組

Archive for September 24th, 2007

數學救亡班 2007

without comments

各位 BUSA01 的同學:

「數學救亡班」是供 BUSA01 副學士先修班同學自由參與的額外數學課,由任教 BUSA01 的導師主持,目的是幫助對數學缺乏信心的同學,追上正規課堂進度。按慣例,「救亡班」於每年的十月開始每週舉行,直至上學期完結為止。

由張真人主持的本學期第一次「數學救亡班」,定於十月第一個星期舉行,歡迎所有 BUSA01 同學參加。暫定詳情如下:

  • 第一班:Mondays, 09:30-10:30(十月八日 至 學期完結)
  • 第二班:Wednesdays, 11:30-12:30 (十月三日 至 學期完結)

地點為 NAB-113 (General Science Laboratory),屆時請帶備教科書、草稿紙及文具。

註:「救亡班」時間跟部份諮詢時段 (consultation hours) 重疊。各 ISM001 的副學士同學,請盡量利用其它諮詢時段,或另外跟我預約其他時間。多謝合作。

Written by 張真人

September 24th, 2007 at 5:15 pm

Posted in BUSA01

ISM001 Class Summary (3)

without comments

Our third class saw some difficulty as some students got screwed up with the OOP stuff. In addition to the points mentioned in the last class summary, let me further clarify a little bit:

  1. The use of setCourseName and getCourseName as the names of the methods is a convention rather than a rule of Java. For example, you can use abc in place of setCourseName and xyz in place of getCourseName. The javac compiler would not complain provided that the naming is consistent throughout your program. However, the convention makes it easier for programmers to understand what the methods are about, and therefore it is recommended as a good programming practice.
  2. It is also a convention to use lowercase for the first letter of the method name, and capital letter to indicate the starting point of a new word (see Good Programming Practice 2.12 in your textbook). Therefore, the method that “sets the course name” is named as setCourseName. The same convention applies to the naming of variables, and that is why “course name” is named as courseName.
  3. A similar convention applies to the naming of the class, except that we always start the class name with an uppercase letter, such as GradeBook.

As always, students are recommended to read the textbook, then break the programs by changing some of the names and see what happens.

Below list a few other key points in the third class:

  1. We mentioned the use of constructors to initialize an object. Students should compare the constructor in Fig. 3.10 with the setCourseName method.
  2. I emphasized the initialization of instance variables in a Java class. Although all primitive types are initialized with a default value in Java, this is not always the case in other programming languages. It is a good practice to initialize the instance values by yourself. For example, use private double balance = 0.0; in line 7 of Fig. 3.13.
  3. Students should break the program in the following way: In Fig. 3.11, change line 11 to GradeBook gradeBook1 = new GradeBook(); (i.e. remove the string between the brackets) and see what happens. Why didn’t we have this problem in the previous examples?
  4. We learned about floating points numbers and the type double in Section 3.8. Pay attention to how we initialize the Account objects in lines 10 and 11 of Fig. 3.14. Also note the use of an if-statement in line 14 of Fig. 3.13.
  5. How do we specify the number of decimal places displayed in the printf method?
  6. For Chapter 4, I intensionally skipped Sections 4.1 to 4.7 in the class because these cannot be well understood without trying a few programs on your own. In Section 4.8, I showed you how to use a while-loop to repeatedly ask the user for inputs. I also emphasized the importance of the statement gradeCounter = gradeCounter + 1; (line 57, Fig. 4.6) to increment the counter in each loop. Apart from the fun with the infinite loop by commenting out this statement, students should remember the missing of this statement as a frequently seen error among junior programmers.
  7. As a final remark, I emphasized the problem of getting only the integer part of the answer if you divide an integer by another integer in Java (see line 61, Fig. 4.6). This is called integer division and is seen also in C/C++. Line 72 of Fig. 4.9 tells you how to fix the problem.

Please read Sections 3.7, 3.8, 4.1 to 4.8 and try the exercise problems before the next class. We are moving into the more advanced topics of the course and it is important for students to gain enough programming and debugging experience before moving on.

Powered by ScribeFire.

Written by 張真人

September 24th, 2007 at 10:02 am

Posted in Class summary, ISM001

Close
E-mail It