2007年11月30日 星期五

Homework 11-30-2007

Do Temperature Project, which is Project 7 (3rd, 2nd ed.) or Project 3 (1st ed.).


這次作業最大的問題好像是看懂題目~"~
我想題目應該是...
寫出兩個method來接收溫度
包含數字部份以及溫度的規格
所以基本就是要有接收兩組溫度的method(getData)(後面要比較)
有了兩組之後就是要有比較的method(comparison)
最後要有toString()把這些輸出
其中華氏及攝氏的轉換
數字方面只能到小數點後一位(round to nearest tenth of a degree)
接下來就是作業部分

下面是Temperature 的Class主體
由於過於龐大
先print出主體

下面這個是轉換華氏or攝氏的method


接下來是取得溫度的資料的method



輸出的method



還有比較用的method
這部分打了很多
我想也許是有太多不必要的邏輯吧







先把基本配備都弄齊全了
就可以開始RUN囉~

0C vs 32F the same



25C vs 60F 25C > 60F


25C vs 78F 25C < 78F


-40C vs -40F the same


100C vs 212F the same

這次的作業似乎比以前更為複雜
也運用了更多class跟method
也更為深入了

2007年11月29日 星期四

Lab counter

Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test


counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();



Lab Class Definition 3

Do Display 4.7 (3rd, 2nd ed.) or 4.5 (1st ed.). Then use Display 4.8 to call 4.7.

Question
The method setDate has the parameter as setDate(int month, int day, int year).
What kind of changes should be made in its body of codes?

課本的範例




接下來則是練習上課的this

2007年11月15日 星期四

Homework 11/16/2007: lab class definition 2

Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then
1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);
2. At the next line below, add date.readInput();
3. Run the program again. Fix any problems you may encouter along the way.
4. At the last line of your program, add System.out.println(date.month);
and see what happens. Why?


先把Display4.4打出來






接下來把題目中要求的加進去

我們發現date.month是不可見的!!!

根據我們上課的內容表示
是因為我們在class裡面定義month為private variable


我們嘗試著修改為public
再run一次
結果發現
System.out.println(date.month);
這次就可以print出來了!!!



Lab Class Definition


Study Display 4.1 and then do Self-Test Exercise 1.







ftp使用




先抓ftp軟體

http://toget.pchome.com.tw/intro/network_transfer/network_transfer_ftp/20471_dl.html

基本上點選上面那個來抓

FileZilla

抓完之後自行安裝

點選進去之後
打入資料
IP
140.135.9.235
帳密
student
student
通訊埠
21


連線成功後就可以看見有分享的檔案
右鍵用下載
左邊可以選擇儲存的地方