//父类MyMedia
public class MyMedia{
protected String mediaName;
protected float price;
protected String press;
protected String artist;
public MyMedia(String mn,float pri,String pre,String art){
mediaName=mn;
price=pri;
press=pre;
artist=art;
}
public void mediaNameInput(String mn){
mediaName=mn;
}
public void mediaPriceInput(float pri){
price=pri;
}
public void mediaPressInput(String pre){
press=pre;
}
public void mediaArtistInput(String art){
artist=art;
}
}
//子类MyBook
public class MyBook extends MyMedia{
private String editor;
private String publishDate;
private String bookISBN;
public MyBook(String mn,float pri,String pre,String art,String edi,String pub,String isbn){
super(mn,pri,pre,art);
editor=edi;
publishDate=pub;
bookISBN=isbn;
}
public void bookOtherInfo(String edi,String pub,String isbn){
editor=edi;
publishDate=pub;
bookISBN=isbn;
}
public void getBookInfo(){
System.out.println();
System.out.println("书名: "+mediaName);
System.out.println("书的价格:"+price);
System.out.println("书的出版社:"+press);
System.out.println("书的作者:"+artist);
System.out.println("书的editor:"+editor);
System.out.println("书的出版日期:"+publishDate);
System.out.println("书的bookISBN:"+bookISBN);
}
}
//子类MyCD
public class MyCD extends MyMedia{
private String cdISRC;
private String cdPublisher;
public MyCD(String mn,float pri,String pre,String art,String isrc,String cdp){
super(mn,pri,pre,art);
cdISRC=isrc;
cdPublisher=cdp;
}
public void CDOtherInfo(String isrc,String cdp){
cdISRC=isrc;
cdPublisher=cdp;
}
public void getCDInfo(){
System.out.println();
System.out.println("CD名: "+mediaName);
System.out.println("CD的价格:"+price);
System.out.println("CD的出版社:"+press);
System.out.println("CD的演唱者:"+artist);
System.out.println("CD的cdISRC:"+cdISRC);
System.out.println("CD的发行者:"+cdPublisher);
}
}
//子类MyTape
public class MyTape extends MyMedia{
private String TapeISRC;
public MyTape(String mn,float pri,String pre,String art,String isrc){
super(mn,pri,pre,art);
TapeISRC=isrc;
}
public void TapeOtherInfo(String isrc){
TapeISRC=isrc;
}
public void getTapeInfo(){
System.out.println();
System.out.println("CD名: "+mediaName);
System.out.println("CD的价格:"+price);
System.out.println("CD的出版社:"+press);
System.out.println("CD的演唱者:"+artist);
System.out.println("CD的TapeISRC:"+TapeISRC);
}
}
未完代叙 时间太晚了!!
QQ 383513327