package com.sf._01_treeset_contact;

public class Goods implements Comparable<Goods>{
    private Long goodsId;
    private String name;
    private double price;

    public Goods() {
    }

    public Goods(Long goodsId, String name, double price) {
        this.goodsId = goodsId;
        this.name = name;
        this.price = price;
    }


    @Override
    public int compareTo(Goods o) {
        if(this.price > o.getPrice()){
            return 1;
        }else if(this.price < o.getPrice()){
            return -1;
        }else{
            if(this.getGoodsId() > o.getGoodsId()){
                return 1;
            }else if(this.getGoodsId() < o.getGoodsId()){
                return -1;
            }else{
                return 0;
            }
        }
    }

    /**
     * 获取
     * @return goodsId
     */
    public Long getGoodsId() {
        return goodsId;
    }

    /**
     * 设置
     * @param goodsId
     */
    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return price
     */
    public double getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    public String toString() {
        return "Goods{goodsId = " + goodsId + ", name = " + name + ", price = " + price + "}";
    }
}
