⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productbooks.java

📁 商店管理系统:在控制台实现
💻 JAVA
字号:
/**
 * 
 * @author	达内科技[Tarena Training Group]
 * @version	1.0
 * @since	jdk1.6
 * 定义实体类 ProductBooks
 */
package entity;

public class ProductBooks{
	private String	id;			//图书ID
	private String	name;		//图书名称
	private String	author;		//图书作者
	private String	summary;	//图书摘要
	private double	price;		//图书价格
	private String	comment;	//图书评论
	private String	publisher;	//图书所属出版社
	private int		amount;		//图书库存量
	/**
	 * 无参构造方法,用与构造一个空的图书对象
	 *
	 */
	public ProductBooks(){}
	/**
	 * 构造一个只包含图书id,图书名称,图书库存的图书对象
	 * @param id
	 * @param name
	 * @param amount
	 */
	public ProductBooks(String id,String name,int amount){
		this.id=id;
		this.name=name;
		this.amount=amount;
	}
	/**
	 * 构造一个完整的图书对象,其所有属性必须给予初值
	 * @param id
	 * @param name
	 * @param author
	 * @param summary
	 * @param price
	 * @param comment
	 * @param publisher
	 * @param amount
	 */
	public ProductBooks(String id,String name,String author
			,String summary,double price,String comment,String publisher,int amount){
		this.id=id;
		this.name=name;
		this.author=author;
		this.summary=summary;
		this.price=price;
		this.comment=comment;
		this.publisher=publisher;
		this.amount=amount;
		
	}
	/**
	 * 获得图书对象的库存量
	 * @return int
	 */
	public int getAmount() {
		return amount;
	}
	/**
	 * 实现图书库存量属性的赋值操作
	 * @param amount
	 */
	public void setAmount(int amount) {
		this.amount = amount;
	}
	/**
	 * 获得图书作者属性的赋值操作
	 * @return String
	 */
	public String getAuthor() {
		return author;
	}
	/**
	 * 实现图书作者属性的赋值操作
	 * @param author
	 */
	public void setAuthor(String author) {
		this.author = author;
	}
	/**
	 * 获得图书评论属性的值
	 * @return String
	 */
	public String getComment() {
		return comment;
	}
	/**
	 * 实现图书评论属性的赋值操作
	 * @param comment
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}
	/**
	 * 获得图书ID属性的值
	 * @return String
	 */
	public String getId() {
		return id;
	}
	/**
	 * 实现图书ID属性的赋值操作
	 * @param id
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * 获得图书名称属性的值
	 * @return String
	 */
	public String getName() {
		return name;
	}
	/**
	 * 实现图书名称属性的赋值操作
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * 获得图书价格属性的值
	 * @return double
	 */
	public double getPrice() {
		return price;
	}
	/**
	 * 实现图书价格属性的赋值操作
	 * @param price
	 */
	public void setPrice(double price) {
		this.price = price;
	}
	/**
	 * 获得图书出版社属性的值
	 * @return String
	 */
	public String getPublisher() {
		return publisher;
	}
	/**
	 * 实现图书出版社属性的赋值操作
	 * @param publisher
	 */
	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}
	/**
	 * 获得图书摘要属性的值
	 * @return String
	 */
	public String getSummary() {
		return summary;
	}
	/**
	 * 实现图书摘要属性的赋值操作
	 * @param summary
	 */
	public void setSummary(String summary) {
		this.summary = summary;
	}
	@Override
	public boolean equals(Object book) {
		if(book instanceof ProductBooks){
			ProductBooks tmp_Book=(ProductBooks)book;
			if(tmp_Book.getId().equals(this.id)){
				return true;
			}
		}
		return false;
	}
	@Override
	public String toString() {
		return "|\t"+this.id+"\t|\t"+this.name+"\t|\t"+this.amount+"本\t|\t"+this.price+"¥\t|";
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -