LAB13 Study and Modify the Hanoi tower Java example.
Purpose: 
    (a) Review the recursive example: Hanoi Tower
    (b) Learn to modify example programs
    (c) Learn how to do simple animation
    (d) Learn double buffering when drawing Graphics
    (e) Review using Java Jar file: creating/Using Jar file
                         
Due: 2011/05/31 Tuesday 23:59  星期二晚上!

  請注意: 做好習題請到數位學習網站本題討論區依照規定貼文寫心得報告, 
   且標題 Subject: LAB13 from 學號姓名(當然是你學號與姓名!)
   報告內容是先寫心得、然後幾張執行過程中的畫面佐證、
   再接著是真的可以用的 Applet (使用 <applet ... 看以下習題工作 (4),
   最後才是帶 Line numbers 程式碼方便閱讀;
   注意要把所有檔案和報告資料等都壓縮成可執行的 .jar 檔案當夾檔附件佐證!
   且該 .jar 檔案須可以用 java -jar 該.jar檔案 執行,
   還有, 你報告中的 <applet... > 的 code, archive, codebase 也是指到該.jar檔案!
  More Note: 
      You should also write what you have learned from this Lab.(心得)
      本題心得要包括研究個範例的心得(從 C 版本 hanoi.c 開始研究).


Description(習題工作):
    Modify the example HAHA8.java   (in archive hanoi.jar)
     (1) 先測試 hanoi.htm 配合 hanoi.jar (as Applet)  
         (hanoi.htm 在附件夾檔中)
         你可以用 "檢視原始檔(View Source)" 偷看網頁內容(其實已經這麼多次應該不用看了:)
     (2) 再測試 java -jar hanoi.jar    (把 hanoi.jar 抓回你電腦)
          點按這 抓 hanoi.jar (注意是 ZIP 格式)
         並測試以下各命令: (參看補充說明)
             java -cp hanoi.jar hhh | more
             java -cp hanoi.jar hhh hanoi.java  | more
             java -cp hanoi.jar hanoi
             java -cp hanoi.jar gHanoi2
             java -cp hanoi.jar gHanoi3
             java -cp hanoi.jar HAHAHA
             java -cp hanoi.jar HAHAHA8 
     (3) 從 hanoi.jar 抓出 HAHA8.java, 研究後加以修改:
          至少要改為像 java -cp hanoi.jar HAHAHA  看到的!
            (左下角有時間, 右下角多個 pause/continue 按鈕)
          並把你學號姓名寫在裡面, 
          且要顯示在畫面我的名字下面一列: Modified by 99xxx你學號姓名.
          原則上這樣就可以了, 
           (注意 HAHAHA.java 原始檔沒在 hanoi.jar 內:)
       Extra credit: 
          有時間的同學也可以放入你的照片和聲音(optional),
          自行發揮創意, 修改功能或加入功能!  
           (注意要兼顧其他科目功課, 不要只是沉迷寫程式!) 
     (4) 注意修改後須仍可同時當作 Java Applet 和 Java application; 
         整個壓成一支 .jar 檔案, 在報告中用 <applet archive=... codebase=...
        code=... width=... height=... >   </applet> 指到該 .jar 檔案 
       (要先把該.jar 檔案上傳到你在系上網頁空間或其他免費網頁空間)
     (5) 潑(Post)在討論區的心得必須看得到你的 Applet,
        也要把你那可用 java -jar 執行的 .jar檔案當作夾檔附件方便助教查看!
     * 請注意夾在你報告附件的 .jar 檔案是無法給你 HTML 內的 <applet... 使用的,
       因為 e3.nctu 是用資料庫放該些檔案, 放入的名稱我們也不知道,
      所以這次除了附件夾檔外, 還要先把該 .jar 檔案丟到系上或其他網頁空間讓你Applet指過去用!


補充說明: 
   The file hanoi.jar contains many versions of the Hanoi tower.
 To test (注意大小寫):
    (1) java -jar hanoi.jar     (as Java application)
        java -cp hanoi.jar HAHAHA
        java -cp hanoi.jar HAHA9       
        java -cp hanoi.jar hanoi      (這是C改來的簡單版)
        java -cp hanoi.jar ghanoi     (這圖形版還沒好)
        java -cp hanoi.jar gHanoi2
        java -cp hanoi.jar gHanoi3
        java -cp hanoi.jar HAHA4
        java -cp hanoi.jar HAHA5
        java -cp hanoi.jar HAHA6
        java -cp hanoi.jar HAHA7
        java -cp hanoi.jar HAHA8
        java -cp hanoi.jar gHanoi8 
    (2) Extract files from hanoi.jar and use java classfile to test them.
        use this command to extract all files: 
           jar xvf hanoi.jar  

      If you only want to extract HAHA8.java  : 
           jar xvf hanoi.jar HAHA8.java  
 
      To see the file list in hanoi.jar  :   
           jar tvf hanoi.jar   
    (3) After extracting files, test these: (注意大小寫) 
        hanoi.exe            (這是 C 的版本)
        java hanoi           (這是 C 改來的簡單版)
        java  ghanoi
        java  gHanoi2
        java  gHanoi3
        java  HAHA4
        java  HAHA5
        java  gHanoi5
        java  HAHA6
        java  HAHA7
        java  HAHA8
        java  gHanoi8 
        java  HAHA9
        java  HAHAHA



*** 請儘量早點做下一題! 不要拖到快 due 了才開始!
這是 hanoi.htm 部分內容 : <html> <head> <title>Tower of Hanoi </title> </head> <body> <font color=blue size=6> Tower of Hanoi <hr> <applet code="HAHAHA.class" archive="hanoi.jar" codebase="http://www.cs.nctu.edu.tw/~tsaiwn/oop/03_Labs/Lab13/" width=598 height=500> alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! </applet> <!-- <hr> <a href="HAHAHA.java">The source</a>. ------> </body> </html>
How to create a Jar file that can be run like this way: java -jar jar_file.name java -jar hanoi.jar HTML file if your Java is an Applet: <applet code="HAHAHA.class" archive="hanoi.jar" width=598 height=500> (1) prepare all class files (2) Assume your main program is in class HAHAHA extends Applet (3) There are two ways to generate the .jar file: (a)simply use the following command: jar cvfe jarfile.jar HAHAHA * (b)another way (比較麻煩) First, create a file named MANIFEST.MF (or other name) then, use the following command: jar cvfm jarfile.jar MANIFEST.mf * Note that the MANIFEST.MF should have correct format For example: (重點在 Main-Class: HAHAHA ) 以下是 MANIFEST.MF 內容: Manifest-Version: 1.0 Created-By: 1.5.0_03 (Sun Microsystems Inc.) Main-Class: HAHAHA

點按這 抓 hanoi.jar (注意是 ZIP 格式)
看更多 hanoi.htm
You are the -th visitors to this page.
            回到作業目錄             回到課程目錄