51dev.com IT技术开发者社区

51dev.com 技术开发者社区

双色球大乐透中奖级别计算

代码星球阅读(20)2020-05-23 收藏0次评论

import java.util.Arrays;

/**
 * 双色球相关规则
 *
 * @Author: L.swallow
 * @Date: 2019/12/13 17:33
 */
public class SSQUtil {

    public static void main(String[] args) {
        System.out.println(zhongjiang(new Integer[]{1,2,3,4,5,6},new Integer[] {1,2,3,4,5,6}, 4, 5));
    }
    /**
     * 中奖结果判断
     *
     * @return
     */
    public static Integer zhongjiang(Integer[] yours, Integer[] jiang, Integer yourlanqiu, Integer zhongJianglan) {
        String jiangNum = "";
        Integer num = Arrays.stream(yours).filter(x -> Arrays.asList(jiang).contains(x)).toArray().length;
        jiangNum += num;
        if (yourlanqiu.equals(zhongJianglan)) {
            jiangNum += 1;
        }else {
            jiangNum += 0;
        }
        return LEVEL.getLevel(jiangNum);
    }



}

enum LEVEL {

    LY("61", 1),
    LL("60", 2),
    WY("51", 3),
    WL("50", 4),
    SIY("41", 4),
    SIL("40", 5),
    SANYI("31", 5),
    EY("21", 6),
    YY("11", 6),
    LINGY("01", 6);

    private final Integer level;

    private final String code;

    private LEVEL(final String code, final Integer level) {
        this.level = level;
        this.code = code;
    }

    public static Integer getLevel(String code) {
        for (LEVEL level : LEVEL.values()) {
            if (level.code.equals(code)) {
                return level.level;
            }
        }
        return 0;
    }

}

 

以上就是双色球大乐透中奖级别计算的全部内容。