Java打造CD、DVD数据库

Written by Bruth_Lee in Southwest University of Science And Technology.


Basic operations like this、、、

像这样的基本操作、、、、、

My code is not written in a file,but you can synthesize it.

(我的代码没有写到一个文件里面,但是你可以合成)

接下来,上菜刀、、、

package notepad;

import java.util.ArrayList;

public class Database {
	
	ArrayList<CD> listCD = new ArrayList<CD>();
	ArrayList<DVD> listDVD = new ArrayList<DVD>();
	public void add(CD cd) {
		listCD.add(cd);
	}
	
	public void add(DVD dvd) {
		listDVD.add(dvd);
	}
	
	public void list() {
		for(CD cd : listCD) {
			cd.print();
		}
		System.out.println("This are my favourite films :");
		System.out.println();
		for(DVD dvd : listDVD) {
			dvd.print();
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Written by Bruth_Lee in Southwest University of Science And Technology.");
		System.out.println("This are my favourite songs :");
		System.out.println();
		Database db = new Database();
		db.add(new CD("Carrie", "Tan_xuanyuan", 17, 4, "Very good!"));
		db.add(new CD("告别的时代","Tan_xuanyuan",17,3,"Xuanyuan , I love you!"));
		db.add(new CD("青花瓷","Jay_Zhou",17,3,"地表最强!"));
		db.add(new DVD("战狼2","吴京",60,"He is a hero!"));
		db.add(new DVD("前任3","不详",60,"看的我心痛!"));
		db.list();
	}
}
CD类

package notepad;

public class CD {
	private String title;
	private String artist;
	private int numofTracks;
	private int playingtime;
	private boolean GotIt;
	private String comment;
	public CD(String title, String artist, int numofTracks, int playingtime, String comment) {
		super();
		this.title = title;
		this.artist = artist;
		this.numofTracks = numofTracks;
		this.playingtime = playingtime;
		this.comment = comment;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	public void print() {
		// TODO Auto-generated method stub
		System.out.println("Title : "+title+"   "+"Artist : "+artist);
	
		System.out.println("Comment :"+comment);
		System.out.println();
	}

}

DVD类

package notepad;

public class DVD {
	private String title;
	private String director;
	private int length;
	private String comment;
	
	public DVD(String title, String director, int length, String comment) {
		super();
		this.title = title;
		this.director = director;
		this.length = length;
		this.comment = comment;
	}
	public void print() {
		System.out.println("Title : "+title+"  "+"Director : "+director+" : "+"lenth : "+length);
		
		System.out.println("Comment : "+comment);
		System.out.println();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}



  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

江湖无为

感谢你们的鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值