码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-12-13 19:55:50      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:equal   java   span   als   oid   return   out   eve   lin   

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;
    }

}

 

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

标签:equal   java   span   als   oid   return   out   eve   lin   

原文地址:https://www.cnblogs.com/lewskay/p/12036755.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!