public class OrderBean implements WritableComparable
private Integer order\_id; //整数用 writeInt()和readInt()
private String pdt; //文本类型 用 writeUTF()和readUTF()
private Double price; //浮点数用 writeDouble()和readDouble()
@Override
public void write(DataOutput dataOutput) throws IOException {
dataOutput.writeInt(order\_id);
dataOutput.writeUTF(pdt);
dataOutput.writeDouble(price);
}
@Override
public void readFields(DataInput dataInput) throws IOException {
this.order\_id=dataInput.readInt();
this.pdt=dataInput.readUTF();
this.price=dataInput.readDouble();
}
@Override
public String toString() {
return order\_id+"\\t"+pdt+"\\t"+price;
}
@Override
public int compareTo(OrderBean o) {
int i = Integer.compare(order\_id,o.getOrder\_id());
if (i!=0)
return i;
return Double.compare(o.getPrice(),price);
}
public Integer getOrder\_id() {
return order\_id;
}
public void setOrder\_id(Integer order\_id) {
this.order\_id = order\_id;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getPdt() {
return pdt;
}
public void setPdt(String pdt) {
this.pdt = pdt;
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章