本周我们介绍了以继承方式实现的媒体资料库,在课程代码实现的基础上,请实现一个表达MP3的媒体类型,能和CD、DVD一样存放进这个Database。请提交这个MP3类的代码。如果你认为为了能存放MP3,需要修改Item和Database,也请一并提交Item和Database的代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
package dome; public class MP3 extends Item { private String title; public MP3(String artist, int numofTracks, int playingTime, boolean gotIt, String comment,String title) { super(artist, numofTracks, playingTime, gotIt, comment); this.title = title; } public static void main(String[] args) { // TODO Auto-generated method stub } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
package dome; ? public class Item { private String artist; private int numofTracks; private int playingTime; private boolean gotIt = false; private String comment; public Item(String artist, int numofTracks, int playingTime, boolean gotIt, String comment) { super(); this.artist = artist; this.numofTracks = numofTracks; this.playingTime = playingTime; this.gotIt = gotIt; this.comment = comment; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
package dome; import java.util.ArrayList; public class Database { ArrayList<Item> ItemList = new ArrayList<Item>(); public void add(Item e) { ItemList.add(e); } public static void main(String[] args) { // TODO Auto-generated method stub Database data = new Database(); data.add(new MP3("",10, 30, false, "","title")); } } |
Thank you, An abundance of forum posts!
buy cialis usa
Good posts. Thanks! promethazine bnf
Thanks! Plenty of facts.
canadian viagra
Valuable data. Appreciate it! trust pharmacy canada
Regards. I like this! Levitra Price Cvs
You stated that well. will cbd oil show up on drug test