java代码提答案

/**
 * @description: 销售员实体
 * @author: sfj
 * @Email:2238414084@qq.com
 * @create: 2024-01-04 14:56
 **/
public class Seller implements Comparable<Seller> {

    private String no;

    private String name;

    private int sales1;
    private int sales2;
    private int sales3;
    private int sales4;

    public Seller(String no, String name, int sales1, int sales2, int sales3, int sales4) {
        this.no = no;
        this.name = name;
        this.sales1 = sales1;
        this.sales2 = sales2;
        this.sales3 = sales3;
        this.sales4 = sales4;
    }


    public int getAssemble(){
        return this.sales1+this.sales2+this.sales3+this.sales4;
    }

    @Override
    public String toString() {
        return this.no+" "+this.name+" "+this.getAssemble()+" "+this.dengJi();
    }

    public String dengJi(){
        if (this.getAssemble()>=10000){
            return "优秀";
        }else if(7000<=this.getAssemble() && 9999>=this.getAssemble()){
            return "良好";
        }else if(4000<=this.getAssemble() && 6999>=this.getAssemble()){
            return "及格";
        }else {
            return "不及格";
        }
    }

    @Override
    public int compareTo(Seller o) {
        if(this.getAssemble() == o.getAssemble()){
            return this.no.compareTo(o.no);
        }
        return this.getAssemble()-o.getAssemble()>0?-1:1;
    }
}
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Seller s1 = new Seller("s011","撒贝贝",2195,1700,2020,3875);
        Seller s2 = new Seller("s001","康辉辉",2580,2742,3000,2498);
        Seller s3 = new Seller("s015","尼格格",1802,2731,1420,758);
        Seller s4 = new Seller("s008","朱权权",3472,898,2164,3256);
        //实例化TreeSet对象
        TreeSet<Seller> ts = new TreeSet<>();
        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);

        //for循环增强,遍历treeSet集合
        for (Seller t : ts) {
            System.out.println(t);
        }
    }
}```

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值