package com.sxt.oop.dvd;
/**
* DVD类
* @author ty
*
*/
public class Dvd implements Comparable<Dvd>{
//存放DVD名
private String dvdNames ;
//存放借出状态的数组,false为可借,true为不可借
private boolean status ;
//存放借DVD日期
private String loanDates ;
//DVD借出次数
private int count;
/**
* 构造方法
*/
public Dvd(){
}
public Dvd(String dvdNames) {
this.dvdNames = dvdNames;
}
public Dvd(String dvdNames, boolean status, String loanDates) {
super();
this.dvdNames = dvdNames;
this.status = status;
this.loanDates = loanDates;
}
/**
* set get方法
* @return
*/
public String getDvdNames() {
return dvdNames;
}
public void setDvdNames(String dvdNames) {
this.dvdNames = dvdNames;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String getLoanDates() {
return loanDates;
}
public void setLoanDates(String loanDates) {
this.loanDates = loanDates;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((dvdNames == null) ? 0 : dvdNames.hashCode());
result = prime * result
+ ((loanDates == null) ? 0 : loanDates.hashCode());
result = prime * result + (status ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Dvd other = (Dvd) obj;
if (dvdNames == null) {
if (other.dvdNames != null)
return false;
} else if (!dvdNames.equals(other.dvdNames))
return false;
if (loanDates == null) {
if (other.loanDates != null)
return false;
} else if (!loanDates.equals(other.loanDates))
return false;
if (status != other.status)
return false;
return true;
}
@Override
public String toString() {
return (status?"已借出":"可借")+"\t\t<<"+dvdNames+">>\t\t\t"+(loanDates==null?"":loanDates)+"\t\t"+count+"\n";
}
/**
* 比较借出次数的方法
*/
@Override
public int compareTo(Dvd o) {
return o.count-this.count;
}
/**
* 借出次数自增方法
*/
public void increment(){
count++;
}
}
package com.sxt.oop.dvd;
import java.text.ParseException;
impo