確認テスト(10/14)

氏名[

空欄を埋めてプログラムを完成させなさい。



import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.[            ];

/** イメージを複数個並べて表示する RepeatedImage クラスの定義 */

public class RepeatedImage extends Applet {

    /** イメージ */

       public Image image = null;

    /** イメージ */

       public int number = 1;

    /** 初期設定のメソッド */

       public void [          ]() {

             String source = getParameter("source");
             if( source != null )
                 image = [            ]( getDocumentBase(),  source );
             else
                 image = [            ]( getCodeBase(),  "default.gif" );

             number = getIntValue("number");
       }

    /** アプレットの表示を行うメソッド */

       public void [          ]( Graphics g ) {

             int w = image.[            ]( this ); // 横幅
             int h = image.[            ]( this ); // 高さ
             g.drawImage( image, 0, 0, this );   // 読み込みを開始させるため
             if( w<=0 || h<=0 )  return;   // サイズ未確定なら何もしない

         // アプレットのサイズに合わせてタイルを縦横に張り込む

             [     ]( int i=0; i<number; i++ )
                g.[            ]( image, i*w, 0, this );
       }

    /** パラメータの文字列を解釈するメソッド */

       protected int getIntValue( String name ) {

             String word = getParameter( name );
             if( word == null )   // 値が与えられていない
                 return 1;
             int value = Integer.parseInt( word );
             if( 0 <= value  || value <= 100 )    // 適切な値の範囲
                 return  value;
             else
                 return 1;
       }
}



<TITLE>RepeatedImage</TITLE>
<H1>
RepeatedImage アプレットのサンプル
</H1>

<APPLET CODE="RepeatedImage.class" WIDTH="600" HEIGHT="24">
<PARAM [       ]="source" [         ]="greentile.gif">
<PARAM [       ]="number" [         ]="50">
</APPLET>
<P>

<APPLET CODE="RepeatedImage.class" WIDTH="480" HEIGHT="48">
<PARAM [       ]="source" [         ]="zou.gif">
<PARAM [       ]="number" [         ]="10">
</APPLET>