welcome: please sign in
location: "リスト処理の演習"の差分
12と13のリビジョン間の差分
2010-11-15 12:58:27時点のリビジョン12
サイズ: 971
編集者: masahiko
コメント:
2010-11-15 12:59:37時点のリビジョン13
サイズ: 1091
編集者: masahiko
コメント:
削除された箇所はこのように表示されます。 追加された箇所はこのように表示されます。
行 49: 行 49:

ヒント
 . 作業用の変数が1つ必要です。
行 52: 行 55:

ヒント
 . 作業用の変数が1つ必要です。

課題07

Chainクラスを作成し、次のいずれかを行うmainメソッドを記述しなさい。

  •    1 public class Chain
       2 {
       3         Chain next;
       4 
       5         void show()
       6         {
       7                 System.out.println(this);
       8         }
       9 
      10         void showAll()
      11         {
      12                 Chain c;
      13 
      14                 c = this;
      15                 System.out.println("(");
      16                 while(c != null)
      17                 {
      18                         c.show();
      19                         c = c.next;
      20                 }
      21                 System.out.println(")");
      22         }
      23         
      24         public static void main(String[] args)
      25         {
      26                 Chain a, b, c;
      27                 ...
      28         }
      29 }
    


1. (初級)

mainメソッド内の変数a,b,cが図のようなオブジェクトを参照しているようにした後

  • a.showAll();
    b.showAll();
    c.showAll();

を行って動作を確かめなさい。


2. (中級)

初級と同じ動作を、 next.next のような記述をしないで行いなさい。

ヒント

  • 作業用の変数が1つ必要です。


3. (上級)

初級で作成しているインスタンスを次の順で作成するようにしなさい。

ヒント

  • 作業用の変数が1つ必要です。

リスト処理の演習 (最終更新日時 2012-03-27 05:02:27 更新者 masahiko)