특정 키워드에 대해 내가 3 개 수업을... 내가 뭘 원하는 것은 키워드와 HashSet의 검색입니다
...
- 주()
- 라이브러리 컬렉션을 검색
- 항목 (CD, DVD, 도서 클래스) 라이브러리에서
내가 hashsets의 항목 내 검색을 수행하려고 ..
을 내가 getKeywords 기능이 곳 Item 클래스에서는
여기할 항목 클래스는 ...
import java.io.PrintStream;
import java.util.Collection;
import java.util.*;
class Item
{
private String title;
private String [] keywords;
public String toString()
{
String line1 = "title: " + title + "\n" + "keywords: " + Arrays.toString(keywords);
return line1;
}
public void print()
{
System.out.println(toString());
}
public Item()
{
}
public Item(String theTitle, String... theKeyword)
{
this.title = theTitle;
this.keywords = theKeyword;
}
public String getTitle()
{
return title;
}
public String [] getKeywords()
{
return keywords;
}
}
class CD extends Item
{
private String artist;
private String [] members;
// private String [] keywords;
private int number;
public CD(String theTitle, String theBand, int Snumber, String... keywords)
{
super(theTitle, keywords);
this.artist = theBand;
this.number = Snumber;
// this.keywords = keywords;
}
public void addband(String... member)
{
this.members = member;
}
public String getArtist()
{
return artist;
}
public String [] getMembers()
{
return members;
}
// public String [] getKeywords()
// {
// return keywords;
//}
public String toString()
{
return "-Music-" + "\n"
+ "band: " + artist + "\n"
+ "# songs: " + number + "\n"
+ "members: " + Arrays.toString(members)
+ "\n" + super.toString()
// + "keywords: " + Arrays.toString(keywords)
+ "\n" + "\n" ;
}
public void print()
{
System.out.println(toString());
}
}
class DVD extends Item
{
private String director;
private String [] cast;
private int scenes;
// private String [] keywords;
public DVD(String theTitle, String theDirector, int nScenes, String... keywords)
{
super(theTitle, keywords);
this.director = theDirector;
this.scenes = nScenes;
// this.keywords = keywords;
}
public void addmoviecast(String... members)
{
this.cast = members;
}
public String [] getCast()
{
return cast;
}
public String getDirector()
{
return director;
}
// public String [] getKeywords()
// {
// return keywords;
// }
public String toString()
{
return "-Movie-" + "\n"
+ "director: " + director + "\n"
+ "# scenes: " + scenes + "\n"
+ "cast: " + Arrays.toString(cast) + "\n"
+ super.toString()
// + "keywords: " + Arrays.toString(keywords)
+ "\n" + "\n" ;
}
public void print()
{
System.out.println(toString());
}
}
class Book extends Item
{
private String author;
private int pages;
public Book(String theTitle, String theAuthor, int nPages, String... keywords)
{
super(theTitle, keywords);
this.author = theAuthor;
this.pages = nPages;
// this.keywords = keywords;
}
public String getAuthor()
{
return author;
}
//public String [] getKeywords()
// {
// return keywords;
//}
public void print()
{
System.out.println(toString());
}
public String toString()
{
return "-Book-" + "\n"
+ "Author: " + author + "\n"
+ "# pages " + pages + "\n"
+ super.toString()
// + "keywords: " + Arrays.toString(keywords)
+ "\n" + "\n" ;
}
}
나는 내가 당신을 혼란 didnt는 희망 ..입니까? 무엇입니다
.. 나는 처음 키워드에 전달되는
는 "공상 과학 소설"입니다 있습니다 .. itemsForKeyword (문자열 키워드) 함수를 사용하여 도움이 필요하고 난 세트의 키워드를 검색하고 일치하는 항목을 반환하려면 나는 그렇게 잘못하고 있니? 감사합니다.
이 http://stackoverflow.com/questions/2293570 –