日期:2014-05-20 浏览次数:20720 次
public abstract class Media {
public String name;
public String authorName;
public abstract String toString();
public Media(String name,String authorName){
this.name=name;
this.authorName=authorName;
}
}
class Book extends Media {
public String name;
public String authorName;
public Book(String name,String authorName){
super(name,authorName);
this.name=name;
this.authorName=authorName;
}
public String toString(){
String message="书名为"+name+",作者是"+authorName+"";
return message;
}
}
class Newspapper extends Media{
public String name;
public String authorName;
public Newspapper(String name,String authorName){
super(name,authorName);
this.name=name;
this.authorName=authorName;
}
public String toString(){
String message="报名为"+name+",编辑是"+authorName+"";
return message;
}
}
import java.util.*;
public class Manage {
public static ArrayList<Media> a=new ArrayList<Media>();
public static void find(String name){
Iterator<Media> ite=a.iterator();
while(ite.hasNext()){
Media exe=ite.next();
if(exe.name==name