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

📄 book.java

📁 使用swing做的熟悉控件使用的DEMO
💻 JAVA
字号:
package book;import java.util.HashSet;import java.util.Iterator;import java.util.Collection;import java.util.ArrayList;import userexception.*;/*** class Book*/public class Book {	private int bookid;	private String name;	private String author;	private int booktype;	private double cost;	private String from;        public static final int COMPUTER = 0;        public static final int NONCOMPUTER = 1;	public static final String KEY = "KEY";	public static final String NAME = "NAME";	public static final String AUTHOR = "AUTHOR";	public static final String TYPE = "TYPE";	public static final String COST = "COST";	public static final String PUBLISH = "PUBLISH";		//constructor	public Book(int bookid, String name, String author, int booktype, double cost, String from) {		this.bookid = bookid;		this.name = name;		this.author = author;		this.booktype = booktype;		this.cost = cost;		this.from = from;	}	//getters and setters	public int getBookId() {		return bookid;	}	public double getCost() {		return cost;	}	public String getName() {		return name;	}	public String getAuthor() {		return author;	}	public String getFrom() {		return from;	}	public int getBookType() {		return booktype;	}		public void setBookId(int id) {		this.bookid = id;	}	public void setName(String name) {		this.name = name;	}	public void setAuthor(String author) {		this.author = author;	}	public void setFrom(String from) {		this.from = from;	}	public void setBookType(int booktype) {		this.booktype = booktype;	}	public void setCost(double cost) {		this.cost = cost;	}	//overridding toString()	public String toString() {		String strTmp = "";		if(this.booktype == COMPUTER) {			strTmp = "Book Type => " + "COMPUTER";		}else {			strTmp = "Book Type => " + "NONCOMPUTER";		}		return ("/*************************/" +		"\nBook ID => " + this.bookid +		"\nBook Name => " + this.name +		"\nBook Author => " + this.author +		"\nBook Cost => " + this.cost +		"\n" + strTmp +		"\nPublishing House => " + this.from +		"\n/*************************/");	}	//overridding equals()	public boolean equals(Object o) {		System.out.println("equals");		if(!(o instanceof Book)) return false;		return (name.equals(((Book)o).name) && author.equals(((Book)o).author));	}	public int hashCode() {		return (new Integer(bookid)).hashCode();	}}

⌨️ 快捷键说明

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