きりゅめも。

2005年に一度更新停止しましたが、メインサイト崩壊に伴い復活させました!サイト管理もう追いつかない^^;ただの中年の戯言です!

昨日がんばりましたー

ふー、Javaがんばって4問完成!
いやー、いい仕事しましたよ(謎

ソースはこんなんだったっけ…。(最後の問題のみ)
覚えてないのは使っているOSが違うからです(ごめんなさいっ

interface CDs{
 public String getArtist();
 public String getTitle();
 public String getGenre();
 public boolean artistEquals(String s);
}
class CD implements CDs{
 private String artist, title, genre;

 CD(String a, String t, String g){
  artist = a;
  title = t;
  genre = g;
 }

 public String getArtist(){
  return artist;
 }

 public String getTitle(){
  return title;
 }

 public String getGenre(){
  return genre;
 }

 public boolean artistEquals(String s){
  if(artist == s || title == s || genre == s)
   return true;
  else
   return false;
 }
}

class MusicFreak{
 public static void main(String args){
  String icchi = "Debussy";
  CD cd1 = new CD("DA PUMP", "Rhapsody in Blue", "J-POP");
  CD cd2 = new CD("Debussy", "月の光", "CLASSIC");
  // そのほか、8曲 計10曲(ぁ
  CDs cds = new CDs[10];
  cds[0] = cd1;
  cds[1] = cd2;
  cds[2] = cd3;
  cds[3] = cd4;
  cds[4] = cd5;
  cds[5] = cd6;
  cds[6] = cd7;
  cds[7] = cd8;
  cds[8] = cd9;
  cds[9] = cd10;
  int s = 0;
  for(int i = 0; i < cds.length; i++){
   int f = i + 1;
   if(cds[i].artistEquals(icchi))
    System.out.println("一致したCD" + f + "\nアーティスト名 : " + cds[i].getArtist() + "\nタイトル名 : " + cds[i].getTitle() + "\nジャンル名 : " + cds[i].getGenre() + "\n");
   s++;
  }
  if(s == 0)
   System.out.println("一致するCDはありませんでした。");
  else
   System.out.println(s + "件がヒットしました。");
  
  for(int i = 1; i <= cds.length; i++){
   //てきとーにプログラムに入ってるCDデータを表示。
  } 
 }
}

こんな感じです。
…うちの学校の誰か、見つけるだろうか。。(汗