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出來了!!!
2 則留言:
Great jobs on step by step explanation.
Thanks!!! :)
張貼留言