精华内容
下载资源
问答
  • 最近在做一个彩票缩水工具,找了几个图片复选框插件始终感觉不太满意,自己动手山寨了一下imageTick插件.
  • 最近在做一个彩票缩水工具,找了几个图片复选框插件始终感觉不太满意,自己动手山寨了一下imageTick插件. 先上效果图: html: 代码 <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection...

    最近在做一个彩票缩水工具,找了几个图片复选框插件始终感觉不太满意,自己动手山寨了一下imageTick插件.

    先上效果图:

    1_091213030407_1.jpg

    html:

     

    ContractedBlock.gif ExpandedBlockStart.gif 代码
    
       
    < asp:CheckBoxList ID ="CheckBoxList1" runat ="server" RepeatDirection ="Horizontal" RepeatLayout ="Flow" Width ="280px" >
    < asp:ListItem > 01 </ asp:ListItem >
    < asp:ListItem > 02 </ asp:ListItem >
    < asp:ListItem > 03 </ asp:ListItem >
    < asp:ListItem > 04 </ asp:ListItem >
    < asp:ListItem > 05 </ asp:ListItem >
    < asp:ListItem > 06 </ asp:ListItem >
    < asp:ListItem > 07 </ asp:ListItem >
    < asp:ListItem > 08 </ asp:ListItem >
    < asp:ListItem > 09 </ asp:ListItem >
    < asp:ListItem > 10 </ asp:ListItem >
    < asp:ListItem > 11 </ asp:ListItem >
    < asp:ListItem > 12 </ asp:ListItem >
    < asp:ListItem > 13 </ asp:ListItem >
    < asp:ListItem > 14 </ asp:ListItem >
    < asp:ListItem > 15 </ asp:ListItem >
    < asp:ListItem > 16 </ asp:ListItem >
    < asp:ListItem > 17 </ asp:ListItem >
    < asp:ListItem > 18 </ asp:ListItem >
    < asp:ListItem > 19 </ asp:ListItem >
    < asp:ListItem > 20 </ asp:ListItem >
    < asp:ListItem > 21 </ asp:ListItem >
    < asp:ListItem > 22 </ asp:ListItem >
    < asp:ListItem > 23 </ asp:ListItem >
    < asp:ListItem > 24 </ asp:ListItem >
    < asp:ListItem > 25 </ asp:ListItem >
    < asp:ListItem > 26 </ asp:ListItem >
    < asp:ListItem > 27 </ asp:ListItem >
    < asp:ListItem > 28 </ asp:ListItem >
    < asp:ListItem > 29 </ asp:ListItem >
    < asp:ListItem > 30 </ asp:ListItem >
    < asp:ListItem > 31 </ asp:ListItem >
    < asp:ListItem > 32 </ asp:ListItem >
    < asp:ListItem > 33 </ asp:ListItem >
    </ asp:CheckBoxList >

     

    JS:

     

    
      
    1 ( function ($){
    2
    3 $.fn.imagecheckbox = function (options) {
    4
    5 var defaults = {
    6 checked: " images/radio.gif " ,
    7 unchecked: " no_images/radio.gif " ,
    8 css: " on " ,
    9 hide_radios_checkboxes: false
    10 };
    11
    12 var opt = $.extend(defaults, options);
    13
    14 this .each( function (){
    15
    16 var obj = $( this );
    17 var type = obj.attr( ' type ' );
    18 var id = obj.attr( ' id ' );
    19
    20 if ( ! opt.hide_radios_checkboxes){
    21 obj.css( ' display ' , ' none ' );
    22 }
    23
    24 if (obj.attr( ' checked ' )){
    25 $( " label[for=' " + id + " '] " ).attr( ' class ' ,opt.css);
    26 } else {
    27 $( " label[for=' " + id + " '] " ).attr( ' class ' , ' out ' );
    28 }
    29
    30 $( " label[for=' " + id + " '] " ).click( function (){
    31 $( " # " + id).trigger( " click " );
    32 if ($( this ).attr( ' class ' ) == opt.css){
    33 $( this ).attr( ' class ' , ' out ' );
    34 } else {
    35 $( this ).attr( ' class ' , opt.css);
    36 }
    37 });
    38
    39 });
    40 }
    41
    42 })(jQuery);

     

    使用方式:(把css一起发出来)

     

    
      
    1 < script type ="text/javascript" src ="/scripts/imagetick.js" ></ script >
    2   < script type ="text/javascript" >
    3 $( function (){
    4 $( " input[type='checkbox'] " ).imagecheckbox({ // the selector can be a class as well
    5   checked: " /images/red.gif " ,
    6 onchecked: " /images/no_check.gif " ,
    7 css: " on "
    8 });
    9 });
    10   </ script >
    11   < style type ="text/css" >
    12 input {}
    13 label { display : inline-block ; width : 25px ; height : 22px ; padding-top : 3px ; text-align : center ; font : 800 12px/150% arial ; position : relative ; left;-210px; }
    14 .on { background : url(/images/red.gif) no-repeat ; }
    15 .out { background : url(/images/no_check.gif) no-repeat ; }
    16   </ style >

     

    转载于:https://www.cnblogs.com/viaivi/archive/2010/04/12/1710380.html

    展开全文
  • package com.clm.javase.lotteryticket.service; import ... ... public class MainProgram { public static void mainProgram() { System.out.println("欢迎使用彩票选号系统!.
     

    彩票选号系统,要求:

    1、可选彩票种类,如福彩、体彩

    2、可选机选、手选

    3、可选单式、复式、胆拖

    4、可选几注

    5、若为复式或胆拖可选几个红号或蓝号

    下面是代码。我用了几天时间,不断修改,总算实现功能了。但总感觉代码比较乱,各种命名、结构等也不规范。相信各位,提点建议

    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    
    public class MainProgram {
        public static void mainProgram() {
            System.out.println("欢迎使用彩票选号系统!");
            System.out.println("作者:");
            CaiPiao caiPiao = SelectChaiPiao.selectChaiPiao();
            //选择选号方式(1机选、2手选)
            IGenerate iGenerate = SelectMode.selectMode();
            //选择选号类型 1单式、2复式、3胆拖
            SelectType selectType = SelectXuanHaoType.selectXuanHaoType();
            selectType.buy(caiPiao, iGenerate);
        }
        //主程序入口
        public static void main(String[] args) {
            mainProgram();
        }
    }
    package com.clm.javase.lotteryticket.bean;
    
    /**
     * 彩票父类
     */
    public class CaiPiao {
        static String NAME;
        static int CODE;
        static int[] arrRed;
        static int redBound;
        static int[] arrBlue;
        static int blueBound;
    
        public String getNAME() {
            return NAME;
        }
    
        public int getCODE() {
            return CODE;
        }
    
        public int[] getArrRed() {
            return arrRed;
        }
    
        public int getRedBound() {
            return redBound;
        }
    
        public int[] getArrBlue() {
            return arrBlue;
        }
    
        public int getBlueBound() {
            return blueBound;
        }
    }

     

    package com.clm.javase.lotteryticket.bean;
    
    /**
     * 福彩子类
     */
    public class FuChai extends CaiPiao {
        //彩票名称
        final private static String NAME = "福彩";
        //编号
        final private static int CODE = 1;
        //红色球数量 6个
        final private static int[] arrRed = new int[6];
        //红色球取值范围 33
        final private static int redBound = 33;
        //蓝色球数量6
        final private static int[] arrBlue = new int[1];
        //蓝色球取值范围 16
        final private static int blueBound = 16;
    
        public String getNAME() {
            return NAME;
        }
    
        public int getCODE() {
            return CODE;
        }
    
        public int[] getArrRed() {
            return arrRed;
        }
    
        public int getRedBound() {
            return redBound;
        }
    
        public int[] getArrBlue() {
            return arrBlue;
        }
    
        public int getBlueBound() {
            return blueBound;
        }
    }
    package com.clm.javase.lotteryticket.bean;
    
    /**
     * 体彩子类
     */
    public class TiChai extends CaiPiao {
        final private static String NAME = "体彩";
        final private static int CODE = 2;
        final private static int[] arrRed = new int[5];
        final private static int redBound = 35;
        final private static int[] arrBlue = new int[2];
        final private static int blueBound = 12;
    
        public String getNAME() {
            return NAME;
        }
    
        public int getCODE() {
            return CODE;
        }
    
        public int[] getArrRed() {
            return arrRed;
        }
    
        public int getRedBound() {
            return redBound;
        }
    
        public int[] getArrBlue() {
            return arrBlue;
        }
    
        public int getBlueBound() {
            return blueBound;
        }
    }
    

     

    package com.clm.javase.lotteryticket.bean;
    
    public class ErShiSanXuanWu extends CaiPiao{
        //彩票名称
        final private static String NAME = "二十三选五";
        //编号
        final private static int CODE = 3;
        //红色球数量 5个
        final private static int[] arrRed = new int[5];
        //红色球取值范围 23
        final private static int redBound = 23;
        //蓝色球数量0
        final private static int[] arrBlue = new int[0];
        //蓝色球取值范围 0
        final private static int blueBound = 0;
    
        @Override
        public String getNAME() {
            return NAME;
        }
    
        @Override
        public int getCODE() {
            return CODE;
        }
    
        @Override
        public int[] getArrRed() {
            return arrRed;
        }
    
        @Override
        public int getRedBound() {
            return redBound;
        }
    
        @Override
        public int[] getArrBlue() {
            return arrBlue;
        }
    
        @Override
        public int getBlueBound() {
            return blueBound;
        }
    }

     

    package com.clm.javase.lotteryticket.impl;
    
    /**
     * 工具类好像没有必要实现接口,因为实现接口就是多态,与工具类的便捷应用是相违背的。
     * 但好像看过一个案例,比如各种支付方式,是可以有共同接口的。
     * 若以后想扩展更多的generate()方式,使用接口应该是可以的。
     * 但是应该把实现类的静态方法改写为非静态的
     */
    
    public interface IGenerate {
        public int[] generate(int[] arr, int bound);
    }
    

     

    package com.clm.javase.lotteryticket.utils;
    
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import java.util.Arrays;
    import java.util.Random;
    
    /**
     * 这个类用来生成n个不重复的随机数,并赋给数组
     * 包括两个静态方法generate(),,用到了IsRepeat类中的noRepeat()方法判断是复复
     */
    public class RandomNumber implements IGenerate {
        /**
         * 用来生成arr.length个数的随机数,范围为bound,如果不重复则赋值给数组arr
         * 注:因为实现多态,所在把原来静态的generate方法改为非静态方法
         * @param arr   传入的数组,用于接收随机数
         * @param bound 随时生成的范围,生成的数m包括本数,不包括0
         * @return int[] 返回赋值后的数组,用于调用者调用该数组后对数组进行输出等动作
         */
        public int[] generate(int[] arr, int bound) {
            Random random = new Random();
            int index = 0;
            while (index < arr.length) {
                // + 1 区间在 1 - (bound  + 1) 之间
                int num = random.nextInt(bound) + 1;
                if (IsRepeat.noRepeat(arr, num)) {
                    arr[index++] = num;
                }
            }
            //对赋值生的数组进行大小排序
            Arrays.sort(arr);
            return arr;
        }
    }
    package com.clm.javase.lotteryticket.utils;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import java.util.Arrays;
    import java.util.Scanner;
    
    /**
     * 这个类用于输入号码
     */
    
    public class ManualNumber implements IGenerate {
        /**
         * 用来通过控制台手动输入arr.length个号码。
         * 注:因为实现多态,所在把原来静态的generate方法改为非静态方法
         * @param arr   数组
         * @param bound 输入的号码的范围,为1-bound
         * @return 返回赋值后的数组,以便调用者拿到该数组后对它进行后续操作
         */
        public int[] generate(int[] arr, int bound) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入:(" + arr.length + "个,范围为:1 -" + bound + ")");
            int index = 0;
            while (index < arr.length) {
                int num = scanner.nextInt();
                if (num > bound || num < 1) {
                    System.out.println("输出的号码超范围,请重新输入");
                } else if (IsRepeat.noRepeat(arr, num)) {
                    arr[index++] = num;
                } else {
                    System.out.println("输入的号码重复,请重新输入:");
                }
            }
            //对赋值后的数组进行排序
            Arrays.sort(arr);
            return arr;
        }
    }

     

    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.bean.ErShiSanXuanWu;
    import com.clm.javase.lotteryticket.bean.FuChai;
    import com.clm.javase.lotteryticket.bean.TiChai;
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectChaiPiao {
        /**
         * 选择彩票
         * @return c1为福彩,c2为体彩
         */
        public static CaiPiao selectChaiPiao() {
            CaiPiao c1 = new FuChai();
            CaiPiao c2 = new TiChai();
            CaiPiao c3 = new ErShiSanXuanWu();
            System.out.println("请选择彩票种类(1福彩、2体彩、3二十三选五):");
            int sct = WrongInput.isWrongInput(3, "您输入的彩票类型不合法,请重新输入(1福彩、2体彩、3二十三选五):");
            if (sct == 1) {
                return c1;
            } else if(sct == 2){
                return c2;
            }else {
                return c3;
            }
        }
    }
    
    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import com.clm.javase.lotteryticket.utils.PrintArrs;
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectDanShiType extends SelectType {
        private static String name = "单式";
    
        @Override
        public String getName() {
            return name;
        }
    
        @Override
        public void buy(CaiPiao caiPiao, IGenerate iGenerate) {
            System.out.println("请输入彩票数量(1-100之间):");
            int num = WrongInput.isWrongInput(100, "输入的数量不合法,请重新输入:");
            int flag = 1;
            while (flag <= num) {
                /*
                下方输出格式为:
                红球: 5 14 17 18 26 33 ; 蓝球: 3
                红球: 9 19 21 23 24 25 ; 蓝球: 13
                 */
                iGenerate.generate(caiPiao.getArrRed(), caiPiao.getRedBound());
                System.out.print("红球: ");
                PrintArrs.print(caiPiao.getArrRed());
                System.out.print("; ");
                iGenerate.generate(caiPiao.getArrBlue(), caiPiao.getBlueBound());
                System.out.print("蓝球: ");
                PrintArrs.print(caiPiao.getArrBlue());
                System.out.println();
                flag++;
            }
        }
    }

     

    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import com.clm.javase.lotteryticket.utils.PrintArrs;
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectDanTuoType extends SelectType {
        private static String name = "胆拖";
    
        @Override
        public String getName() {
            return name;
        }
    
        public void buy(CaiPiao caiPiao, IGenerate iGenerate) {
            System.out.println("请输入彩票数量(1-100之间):");
            int num = WrongInput.isWrongInput(100, "输入的数量不合法,请重新输入:");
            int flag = 1;
            System.out.println("请输入红球担个数:(1 - " + caiPiao.getRedBound() + "之间)");
            int numRedDan = WrongInput.isWrongInput(1, caiPiao.getRedBound(), "输入的个数不合法,请重新输入:");
            System.out.println("请输入红球拖个数:(1 - " + caiPiao.getRedBound() + "之间)");
            int numRedTuo = WrongInput.isWrongInput(1, caiPiao.getRedBound(), "输入的个数不合法,请重新输入:");
            System.out.println("请输入复式蓝球个数:(" + (caiPiao.getArrBlue().length + 1) + " - " + caiPiao.getBlueBound() + "之间)");
            int numBlue = WrongInput.isWrongInput(caiPiao.getArrBlue().length + 1, caiPiao.getBlueBound(), "输入的个数不合法,请重新输入:\"");
            while (flag <= num) {
                /*下方输出格式为:
                红球-胆: 1 12 13 32 ; 红球-拖: 1 2 5 12 19 28 32 ; 蓝球: 1 13
                红球-胆: 3 17 18 24 ; 红球-拖: 13 14 15 19 22 25 29 ; 蓝球: 2 11
                红球-胆: 3 10 15 20 ; 红球-拖: 1 4 12 21 24 31 33 ; 蓝球: 5 16
                 */
    
                int[] danRedArr = new int[numRedDan];
                int[] tuoRedArr = new int[numRedTuo];
                int[] dtFuBlueArr = new int[numBlue];
                iGenerate.generate(danRedArr, caiPiao.getRedBound());
                System.out.print("红球-胆: ");
                PrintArrs.print(danRedArr);
                System.out.print("; ");
    
                iGenerate.generate(tuoRedArr, caiPiao.getRedBound());
                System.out.print("红球-拖: ");
                PrintArrs.print(tuoRedArr);
                System.out.print("; ");
    
                iGenerate.generate(dtFuBlueArr, caiPiao.getBlueBound());
                System.out.print("蓝球: ");
                PrintArrs.print(dtFuBlueArr);
                System.out.println();
                flag++;
            }
        }
    }
    
    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import com.clm.javase.lotteryticket.utils.PrintArrs;
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectFuShiType extends SelectType {
        private static String name = "复式";
    
        @Override
        public String getName() {
            return name;
        }
    
        /**
         * 购买复式彩票的方法
         *
         * @param caiPiao   彩票类型
         * @param iGenerate 机选和手选的接口
         */
        public void buy(CaiPiao caiPiao, IGenerate iGenerate) {
            System.out.println("请输入彩票数量(1-100之间):");
            int num = WrongInput.isWrongInput(100, "输入的数量不合法,请重新输入:");
            int flag = 1;
            System.out.println("请输入复式红球个数:(" + (caiPiao.getArrRed().length + 1) + " - " + caiPiao.getRedBound() + "之间)");
            int numRed = WrongInput.isWrongInput(caiPiao.getArrRed().length + 1, caiPiao.getRedBound(), "输入的个数不合法,请重新输入:");
            System.out.println("请输入复式蓝球个数:(" + (caiPiao.getArrBlue().length + 1) + " - " + caiPiao.getBlueBound() + "之间)");
            int numBlue = WrongInput.isWrongInput(caiPiao.getArrBlue().length + 1, caiPiao.getBlueBound(), "输入的个数不合法,请重新输入:\"");
            while (flag <= num) {
                /*
                下方输出格式为:
                红球: 1 8 13 16 18 20 21 29 ; 蓝球: 2 4 10
                 */
    
                int[] fushiRedArr = new int[numRed];
                int[] fuShiBlueArr = new int[numBlue];
                iGenerate.generate(fushiRedArr, caiPiao.getRedBound());
                System.out.print("红球: ");
                PrintArrs.print(fushiRedArr);
                System.out.print("; ");
                iGenerate.generate(fuShiBlueArr, caiPiao.getBlueBound());
                System.out.print("蓝球: ");
                PrintArrs.print(fuShiBlueArr);
                System.out.println();
                flag++;
            }
        }
    }

     

    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.impl.IGenerate;
    import com.clm.javase.lotteryticket.utils.ManualNumber;
    import com.clm.javase.lotteryticket.utils.RandomNumber;
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectMode {
        private static String randomSelectName = "机选";
        private static String manualSelectName = "手选";
    
        public static String getRandomSelectName() {
            return randomSelectName;
        }
        public static String getManualSelectName() {
            return manualSelectName;
        }
    
        /**
         * 选择机选还是手选
         * @return ig1为机选,ig2为手选
         */
        public static IGenerate selectMode() {
            IGenerate ig1 = new RandomNumber();
            IGenerate ig2 = new ManualNumber();
            System.out.println("请选择选号方式(1机选、2手选):");
            int sm = WrongInput.isWrongInput(2, "您输入的选号方式不合法,请重新输入:(1机选、2手选)");
            if (sm == 1) {
                return ig1;
            } else {
                return ig2;
            }
        }
    }

     

    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.bean.CaiPiao;
    import com.clm.javase.lotteryticket.impl.IGenerate;
    
    public class SelectType {
        //选择类型名称,子类有单式、复式和胆拖
        private String name;
    
        public String getName() {
            return name;
        }
    
        /**
         * 购买方法。需要子类重写
         * @param caiPiao   彩票类型
         * @param iGenerate 机选和手选的接口
         */
        public void buy(CaiPiao caiPiao, IGenerate iGenerate) {
        }
    }
    
    package com.clm.javase.lotteryticket.service;
    
    import com.clm.javase.lotteryticket.utils.WrongInput;
    
    public class SelectXuanHaoType {
        /**
         * 用来选择选号类型 1单式、2复式、3胆拖
         *
         * @return 返回三个变量 selectType1、selectType2、selectType3分别为单式、复式、胆拖
         */
        public static SelectType selectXuanHaoType() {
            SelectType selectType1 = new SelectDanShiType();
            SelectType selectType2 = new SelectFuShiType();
            SelectType selectType3 = new SelectDanTuoType();
            System.out.println("请选择选号类型(1单式、2复式、3胆拖):");
            int sxt = WrongInput.isWrongInput(3, "您输入的选号类型不合法,请重新输入:(1单式、2复式、3胆拖)");
            if (sxt == 1) {
                return selectType1;
            } else if (sxt == 2) {
                return selectType2;
            } else {
                return selectType3;
            }
        }
    }
    

     

    package com.clm.javase.lotteryticket.utils;
    
    public class IsRepeat {
        /**
         * 判断随机数是否与arr内数据重复
         * @param arr 数组
         * @param m   随机生成的数 +1
         * @return 返回false表示重复,返回true表示不重复
         */
        public static boolean noRepeat(int[] arr, int m) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == m) {
                    return false;
                }
            }
            return true;
        }
    }
    
    package com.clm.javase.lotteryticket.utils;
    
    //这个类用于打印数组 ,打印出来的格式如3 4 8 11 22 100 9 45
    public class PrintArrs {
        /**
         * 打印数组
         *
         * @param arr 传入的数组
         */
        public static void print(int[] arr) {
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i] + " ");
            }
    //        System.out.println(); //注释掉该是因为后面调用时不想换行
        }
    }

     

    package com.clm.javase.lotteryticket.utils;
    
    import java.util.Scanner;
    
    /**
     * 这个类用于判断输入值是否合法
     */
    public class WrongInput {
        /**
         * 判断输入是否合法,如无合法需要再次输入一直到输入正确为止
         *
         * @param start 起始范围
         * @param end   结束范围
         * @param str   输入不合法后提醒
         * @return 返回输入的合法值:int类型
         */
        public static int isWrongInput(int start, int end, String str) {
            Scanner sca = new Scanner(System.in);
            int input = 0;
            boolean flag = true;
            while (flag) {
                input = sca.nextInt();
                if (input < start || input > end) {
                    System.out.println(str);
                } else {
                    flag = false;
                }
            }
            return input;
        }
    
        public static int isWrongInput(int end, String str) {
            Scanner sca = new Scanner(System.in);
            int input = 0;
            boolean flag = true;
            while (flag) {
                input = sca.nextInt();
                if (input < 1 || input > end) {
                    System.out.println(str);
                } else {
                    flag = false;
                }
            }
            return input;
        }
    }

    实现的效果如下: 

    未能实现的功能有:

    1、如何根据生成的彩票(如复式或胆拖)生成有几种可能,并分别打印出来。

    2、计算共多少价格。

    展开全文
  • // 机一注彩票 RandomCure(); // 提示用户 vibrator.vibrate( 100 ); // 所有的数据都要初始化 initParam(); } else { lastX = x; lastY = y; lastZ = z; lastTime = System. currentTimeMillis...

    实现思路:因为手机传感器每隔一段时间会发送采集到的数据包, 首先获取第一个数据包所在的三个轴的加速度值,记录, 当过一段时间之后再次获取三个轴的加速度值,计算增量,将相邻两个点的增量进行汇总,当达到预先设定的阀值,说明手机摇晃了。

    实现步骤:
    1、记录第一个点的数据: 三个轴的加速度,为了屏蔽不同手机采样的时间间隔差异,将第一个点的时间也记录下 来。
    2、选取第二个点的数据:当有新的传感器数据传递进来后,用当前的时间与第一个点的时间进行比对,判断时间间 隔,如果满足了时间间隔(经验值:100)的要求,认为是合格的第二个点,否则舍弃改数据包。
    3、 进行增量的计算:获取到的新的加速度值与第一个点上的加速度值进行差值运算,获取到一点和二点之间的增量,将三个增量值进行汇总。
    4、以此类推,获取到相邻两个点的增量,进行汇总。
    5、通过汇总的值与之前设定好的阀值(经验值:200)进行比对,如果>=阀值,用户摇晃手机。否则记录当前点的数据(加速度的值 和 该点的时间)。

    一、核心传感器监听代码:

    package com.huang.mylottery.view.sensor;
    
    import android.content.Context;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.os.Vibrator;
    
    /**
     * 处理传感器监听
     *
     * @author wuseyukui
     *
     */
    public abstract class ShakeListener implements SensorEventListener {
    
          // 判断手机摇晃的阈值
          private final static float SWITH_VALUE = 200f;
          private final static long DURATION = 100;
    
          private Vibrator vibrator;
    
          private float lastX;
          private float lastY;
          private float lastZ;
          private long lastTime;
          private float total;
    
          public ShakeListener(Context context) {
                 super();
                 vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE );
          }
    
    
          private void initParam() {
                 lastX = 0;
                 lastY = 0;
                 lastZ = 0;
                 lastTime = 0;
                 total = 0;
          }
    
    
          @Override
          public void onSensorChanged(SensorEvent event) {
                 // 判断 是否第一个点
                 if ( lastX == 0 && lastY == 0 && lastZ == 0 && lastTime == 0) {
                       // 记录三个轴的加速度值
                       float[] values = event. values;
                       lastX = values[0];
                       lastY = values[1];
                       lastZ = values[2];
                       lastTime = System. currentTimeMillis();
                       total = lastX + lastY + lastZ;
    
                } else {
                       // 尽可能屏蔽掉不同手机传感器的差异
                       if (System. currentTimeMillis() - lastTime > DURATION) {
                             float[] values = event. values;
                             // 第二个点及以后
                             float x = values[0];
                             float y = values[1];
                             float z = values[2];
    
                             // 计算增量
                             float dx = Math. abs(x-lastX);
                             float dy = Math. abs(y-lastY);
                             float dz = Math. abs(z-lastZ);
    
                             // 尽量屏蔽掉微小的增量值
                             if (dx < 1) {
                                  dx = 0;
                            }
                             if (dy < 1) {
                                  dy = 0;
                            }
                             if (dz < 1) {
                                  dz = 0;
                            }
    
                             // 极个别手机,静止状态 某个轴的增量会大于1,10以上,甚至100以上
                             if (dx == 0 && dy == 0 && dz == 0) {
                                  initParam();
                                   return;
                            }
    
                             // 汇总(一点和二点总得增量)
                             float shake = dx + dy + dz;
    
                             if(shake == 0) {
                                  initParam();
                                   return;
                            }
    
                             total += shake;
    
                             if ( total >= SWITH_VALUE) {
                                   // 手机摇晃了
                                   // 机选一注彩票
                                  RandomCure();
                                   // 提示用户
                                   vibrator.vibrate(100);
                                   // 所有的数据都要初始化
                                  initParam();
    
                            } else {
                                   lastX = x;
                                   lastY = y;
                                   lastZ = z;
                                   lastTime = System. currentTimeMillis();
                            }
                      }
                }
          }
    
    
          public abstract void RandomCure();
    
    
          @Override
          public void onAccuracyChanged(Sensor sensor, int accuracy) {
    
          }
    
    }
    
    
    二、注册监听
    
    listener = new ShakeListener(context){
          @Override
          public void RandomCure() {
         //机选一注
         randomSSQ();
       }
     };
     // 注册传感器监听
      sensor.registerListener( listener,
                              sensor.getDefaultSensor(Sensor. TYPE_ACCELEROMETER),
                              SensorManager. SENSOR_DELAY_FASTEST);
    

    二、各种彩票的算法

    package cn.com.soarmobile.lottery;
    
    import android.content.res.TypedArray;
    import cn.com.soarmobile.SoarEngine;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    
    /**
    * Type代表彩种玩法(如:任选一、任选二); Mode代表选号类型(如:直选)
    *
    * @author Administrator
    *
    */
    public abstract class LotteryBase {
         /**
         * 彩种LOGO
         */
         public int icon;
    
         /**
         * 彩种名字 例如排列三
         */
         public String name;
         /**
         * 彩种名字编号 例如排列三:p3 双色球:ssq
         */
         public String gameName;
    
         /**
         * 彩种代号 例如双色球:001 福彩3D:002
         */
         public String code;
         /**
         * 官方规则
         */
         public int officialrule;
    
         /**
         * 奖金说明
         */
         public int prizeexplain;
         /**
         * 彩票期数 例如20110115
         */
         public String issue;
         /**
         * 彩种简介,例如:天天排列3,不愁吃喝穿
         */
         public String summary;
         /**
         * 购买一注的价格
         */
         public int price;
         /**
         * 购买截止时间
         */
         public String deadLine;
         /**
         * 红色选号区标签 如只有红色球 则显示选号 蓝球选号区域不显示
         */
         public String redTag;
         /**
         * 蓝色选号区标签 如果木有蓝球 该区域不显示
         */
         public String buleTag;
         /**
         * 最少要选择的红球数 例如双色球至少选6个红球
         */
         public int redMin;
         /**
         * 最少要选择的蓝球数 例如双色球至少选1个蓝球 值可以为0
         */
         public int blueMin;
         /**
         * 选号规则介绍 例如 请选择至少六个红球和一个蓝球
         */
         public String[] rules;
         /**
         * 当前模式选号规则
         */
         public String currentRule;
         /**
         * 彩种玩法,例如:任选一、任选二
         */
         public String[] playType;
         /**
         * 当前彩种玩法 <br>
         * 参照{@link #playType playType}
         */
         protected String currentType;
         /**
         * 机选玩法,例如:二星、三星、五星 <br>
         * 该玩法目前为{@link #playType playType}的子集
         */
         public String[] autoPlayType = null;
    
         /**
         * 选号类型,例如:直选、组选、通选
         */
         public String[] playMode;
         /**
         * 当前选号类型 <br>
         * 参照{@link #playMode playMode}
         */
         protected String currentMode;
         /**
         * 不同玩法 模式的注意事项提醒
         */
         public String[] notices;
         /**
         * 当前模式注意事项
         */
         public String currentNotice;
    
         /**
         * 是否允许追加
         */
         public boolean allowAddTo = false;
         /**
         * 是否格式化显示号码 例如 双色球01,02,03
         */
         public boolean format = false;
    
         /**
         * 获取红球选号池 例如 :排列三{0,1,2,3,4,5,6,7,8,9} 选号类型和选号模式影响改返回值
         *
         * @return
         */
         /**
         * 根据playtype和playmode计算出来当前索引
         */
         public int currentIndex;
    
         public abstract int[] getRedPool();
    
         protected int[] getRedPool(int resId) {
              String[] redrules = getStringArray(resId);
              String temp = redrules[currentIndex];
              String[] string = temp.split("-");
              int count = Integer.parseInt(string[1]);
              int start = Integer.parseInt(string[2]);
              int end = Integer.parseInt(string[3]);
              return CalculatorUtils.createBalls(count, start, end);
         }
    
         /**
         * 红球选择区的显示时候的列数
         *
         * @return
         */
         public abstract int getRedColumnCount();
    
         protected int getRedColumnCount(int resId) {
              String[] redrules = getStringArray(resId);
              String temp = redrules[currentIndex];
              String[] string = temp.split("-");
              return Integer.parseInt(string[0]);
         }
    
         /**
         * 获取蓝球选号池 例如排列三{0,1,2,3,4,5,6,7,8,9} 选号类型和选号模式影响改返回值
         *
         * @return
         */
         public abstract int[] getBluePool();
    
         protected int[] getBluePool(int resId) {
              String[] redrules = getStringArray(resId);
              String temp = redrules[currentIndex];
              String[] string = temp.split("-");
              int count = Integer.parseInt(string[1]);
              int start = Integer.parseInt(string[2]);
              int end = Integer.parseInt(string[3]);
              return CalculatorUtils.createBalls(count, start, end);
         }
    
         /**
         * 蓝球选择区的显示时候的列数
         *
         * @return
         */
         public abstract int getBlueColumnCount();
    
         protected int getBlueColumnCount(int resId) {
              String[] redrules = getStringArray(resId);
              String temp = redrules[currentIndex];
              String[] string = temp.split("-");
              return Integer.parseInt(string[0]);
         }
    
         /**
         * 机选红球
         */
         public abstract int[] getRandomRed();
    
         /**
         * 机选蓝球
         */
         public abstract int[] getRandomBlue();
    
         /**
         * 机选n注号码
         * 返回int[][]
         */
         public abstract int[][] getRandom(int n);
    
         /**
         * 机选n注号码
         * 返回String[]
         * 这样就不用根据redMin blueMin判断填充那种颜色了,
         * 减少彩种切换时对redMin和blueMin的管理
         */
         public abstract String[] getRandomString(int n);
    
         /**
         * 判断当前选择是否合法
         *
         * @param red
         * @param bule
         * @return
         */
         public abstract boolean isValid(int[] red, int[] bule);
    
         /**
         * 计算当前选了多少注 数学公式C(red,bule)或A(red,bule)
         *
         * @param red
         *            当前选择的红球
         * @param bule
         *            当前选择的蓝球
         * @return 计算出注数
         */
         public abstract long calculatorBoxes(int[] red, int[] bule);
    
         /**
         * 重新为默认设置
         */
         public abstract void reset(boolean isAutoToManual);
    
         /**
         * 根据plaype和playMode获取索引 例如 福彩3d {直选 复式}对应索引0 {直选 單式}对应索引1 {组三 复式}对应索引2
         */
         public int getIndex(int resId) {
              int n = 0;
              for (int i = 0; i < playType.length; i++) {
                   String[] strings = CountModeByType(resId, i);
                   for (int j = 0; j < strings.length; j++) {
                        if (currentType.equals(playType[i])
                                  && currentMode.equals(strings[j])) {
                             return n;
                        }
                        n++;
                   }
              }
    
              for (int i = 0; i < playMode.length; i++) {
                   if (currentMode.equals(playMode[i])) {
                        return n;
                   }
                   n++;
              }
              return n;
         }
    
         /**
         *
         * @return 获取当前选择playType的索引 例如 福彩3d {直选,组三,组六}对应的索引分别为{0,1,2}
         */
         public int getPlayTypeIndex() {
              for (int i = 0; i < playType.length; i++) {
                   if (currentType.equals(playType[i])) {
                        return i;
                   }
    
              }
              return 0;
         }
    
         /**
         *
         * @param resId
         *            R.array.xx_playmodes
         * @param index
         *            当前选择playType的索引 例如 福彩3d {直选,组三,组六}对应的索引分别为{0,1,2}
         * @return 对应plaype下的playmodes 例如 福彩3d直选 {复式 单式}
         */
         public String[] CountModeByType(int resId, int index) {
              TypedArray typedArray = SoarEngine.getInstance().getResources()
                        .obtainTypedArray(resId);
              resId = typedArray.getResourceId(index, -1);
              return getStringArray(resId);
    
         }
    
         /**
         * 彩种playype发生变化 例如 福彩3d{直选 组三}
         */
         public abstract void notifyPlayTypeChanged();
    
         /**
         * 当有的彩种的玩法类型改变时,其redMin或buleMin的值会相应的被改变, 这种情况下,在具体的彩种类中要重写该方法,使玩法类型与redMin
         * 和buleMin相对应。例如,11选5的玩法,任选二 任选三等的最小 红球数不同,切换玩法类型时就要对redMin做相应的改变,否则在自选
         * 和机选间切换时会出问题,因为机选显示号码个数时会用到以上量值。 {@link #setCurrentMode(String)
         * setCurrentMode()}类似。
         *
         * @param currentType
         */
         public void setCurrentType(String currentType) {
              this.currentType = currentType;
              notifyPlayTypeChanged();
         }
    
         public String getCurrentType() {
              return currentType;
         }
    
         /**
         * 彩种playMode发生变化 例如 福彩3d{单式 复式}
         */
         public abstract void notifyPlayModeChanged();
    
         /**
         * 使用说明参考{@link #setCurrentType(String) setCurrentType}
         *
         * @return
         */
         public void setCurrentMode(String currentMode) {
              this.currentMode = currentMode;
              notifyPlayModeChanged();
         }
    
         public String getCurrentMode() {
              return currentMode;
         }
    
         /**
         *
         * @param resId
         *            R.arrat.xx_playmodes
         * @return 当前PlayType对应的PlayMode 例如 福彩3d直选{复式,单式}
         */
         public String[] getPlayModes(int resId) {
              TypedArray typedArray = SoarEngine.getInstance().getResources()
                        .obtainTypedArray(resId);
              resId = typedArray.getResourceId(getPlayTypeIndex(), -1);
              return getStringArray(resId);
    
         }
    
         protected String getString(int resId) {
              return SoarEngine.getInstance().getResources().getString(resId);
         }
    
         protected String[] getStringArray(int resId) {
              return SoarEngine.getInstance().getResources().getStringArray(resId);
         }
    
         protected int getInteger(int resId) {
              return SoarEngine.getInstance().getResources().getInteger(resId);
    
         }
    
         protected boolean getBoolean(int resId) {
              return SoarEngine.getInstance().getResources().getBoolean(resId);
         }
    
         /**
         * 判断当前想要选择的红球是否能被选选择
         *
         * @param selected
         *            当前已经选中的红球
         * @param index
         *            想要选择的红球
         * @return
         */
         public abstract String canSelecteRed(int[] selected, int index);
    
         /**
         * 判断当前想要选择的蓝球是否能被选选择
         *
         * @param selected
         *            当前已经选中的蓝球
         * @param index
         *            想要选择的蓝球
         * @return
         */
         public abstract String canSelecteBlue(int[] selected, int index);
    
         /**
         * 根据当前已选红球和想要选择的红球计算出新的选中状态
         *
         * @param selected
         *            当前已经选中的红球
         * @param index
         * @return
         */
         public abstract int[][] newRedBalls(int[] selected, int index,
                   boolean isCancel);
    
         /**
         * 根据当前已选红球和想要选择的蓝球计算出新的选中状态
         *
         * @param selected
         *            当前已经选中的红球
         * @param index
         * @return
         */
         public abstract int[][] newblueBalls(int[] selected, int index,
                   boolean isCancel);
    
         /**
         * 将当前已经选择的红球格式化为字符串 例如 已经选择3 6 7格式化为3,6,7
         *
         * @param text
         * @param index
         * @return
         */
         public abstract String formatSelectedRed(String[] texts, int[] indexs);
    
         /**
         * 将当前已经选择的蓝球格式化为字符串 例如 已经选择3 6 7格式化为3,6,7
         *
         * @param text
         * @param index
         * @return
         */
         public abstract String formatSelectedBlue(String[] texts, int[] indexs);
    
         //根据当前选号情况创建代表当前选好的彩票订单项目
         /**
         * @param redpool 红球
         * @param bluepool 蓝球
         * @param result 方案信息(X注X元)
         * @param zhuijia 是否追加
         */
         public abstract LotteryCartItem createLotteryCartItem(String redpool,String bluepool,String result,boolean zhuijia);
    
         public abstract int getTypeCodeByMode(String mode);
    }
    
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    public class Lottery11x5 extends LotteryRed {
         public Lottery11x5() {
              icon = R.string.llx5_icon;
              name = getString(R.string.llx5_name);
              gameName = getString(R.string.llx5_game_name);
              code = getString(R.string.llx5_code);
              issue = getString(R.string.llx5_issue);
              summary = getString(R.string.llx5_summary);
              price = getInteger(R.integer.llx5_price);
              deadLine = getString(R.string.llx5_deadline);
              redTag = getString(R.string.llx5_redtag);
              buleTag = getString(R.string.llx5_bluetag);
              redMin = getInteger(R.integer.llx5_redmin);
              blueMin = getInteger(R.integer.llx5_bluemin);
              rules = getStringArray(R.array.llx5_rules);
              notices = getStringArray(R.array.llx5_notices);
              playType = getStringArray(R.array.llx5_playtypes);
              currentType = getString(R.string.llx5_defaulttype);
              playMode = getStringArray(R.array.llx5_playmodes);
              currentMode = getString(R.string.llx5_defaultmode);
              allowAddTo = getBoolean(R.integer.llx5_allowAdd);
              format = getBoolean(R.integer.llx5_format);
              officialrule = R.string.llx5_officialrule;
              prizeexplain = R.string.llx5_prizeexplain;
              autoPlayType = getStringArray(R.array.llx5_auto_playtypes);
              notifyPlayTypeChanged();
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.llx5_redpools);
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.llx5_redpools);
         }
    
         @Override
         public int[] getRandomRed() {
              int n = getIndex(R.array.llx5_playmodes);
              int column = getRedColumnCount();
              switch (n) {
              case 0:// 任一-直选
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 10);
              case 1:// 任二-直选
                   return CalculatorUtils.getRandomArrayNumber(2, 0, 10);
              case 2:// 任三-直选
                   return CalculatorUtils.getRandomArrayNumber(3, 0, 10);
              case 3:// 任四-直选
                   return CalculatorUtils.getRandomArrayNumber(4, 0, 10);
              case 4:// 任五-直选
                   return CalculatorUtils.getRandomArrayNumber(5, 0, 10);
              case 5:// 任六-直选
                   return CalculatorUtils.getRandomArrayNumber(6, 0, 10);
              case 6:// 任七-直选
                   return CalculatorUtils.getRandomArrayNumber(7, 0, 10);
              case 7:// 任八-直选
                   return CalculatorUtils.getRandomArrayNumber(8, 0, 10);
              case 8:// 前二-直选
                   int[] reds = CalculatorUtils.getRandomArrayNumber(2, 0, 10);
                   for (int i = 0; i < reds.length; i++) {
                        reds[i] = reds[i] + column * i;
                   }
                   return reds;
              case 9:// 前二-组选
                   return CalculatorUtils.getRandomArrayNumber(2, 0, 10);
              case 10:// 前三-直选
                   reds = CalculatorUtils.getRandomArrayNumber(3, 0, 10);
                   for (int i = 0; i < reds.length; i++) {
                        reds[i] = reds[i] + column * i;
                   }
                   return reds;
              case 11:// 前三-组选
                   return CalculatorUtils.getRandomArrayNumber(3, 0, 10);
    
              }
              return null;
    
         }
    
         @Override
         public int[][] getRandom(int n) {
              if (n < 1) {
                   n = 1;
              }
              int[][] result = new int[n][redMin];
              for (int i = 0; i < n; i++) {
                   for (int j = 0; j < redMin; j++) {
                        result[i][j] = CalculatorUtils.getRandomNumber(1, 11);
                   }
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              if (n < 1) {
                   n = 1;
              }
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   int[] nums = CalculatorUtils.getRandomArrayNumber(redMin, 1, 11);
                   for (int j = 0; j < redMin; j++) {
                        sBuffer.append(StringUtil.format(nums[j]) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
    
              switch (currentIndex) {
              case 0:// 任一-直选
                   break;
              case 1:// 任二-直选
                   break;
              case 2:// 任三-直选
                   break;
              case 3:// 任四-直选
                   break;
              case 4:// 任五-直选
                   break;
              case 5:// 任六-直选
                   break;
              case 6:// 任七-直选
                   break;
              case 7:// 任八-直选
                   break;
              case 8:// 前二-直选
                   if (red[red.length - 1] / getRedColumnCount() != 1)
                        return false;
              case 9:// 前二-组选
                   break;
              case 10:// 前三-直选
                   if (red[red.length - 1] / getRedColumnCount() != 2)
                        return false;
              case 11:// 前三-组选
                   break;
    
              }
              if (red.length < redMin)
                   return false;
              return true;
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:
              case 1:
              case 2:
              case 3:
              case 4:
              case 5:
              case 6:
              case 7:// 任一-直选 到 任八-直选
                   return CalculatorUtils.calculatorCombination(red.length, redMin);
              case 8:// 前二-直选
                   return CalculatorUtils.calculatorBoxs(red, column);
              case 9:// 前二-组选
                   return CalculatorUtils.calculatorCombination(red.length, redMin);
              case 10:// 前三-直选
                   return CalculatorUtils.calculatorBoxs(red, column);
              case 11:// 前三-组选
                   return CalculatorUtils.calculatorCombination(red.length, redMin);
              }
              return 0;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.llx5_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              playMode = getPlayModes(R.array.llx5_playmodes);
              currentMode = playMode[0];
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.llx5_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[getIndex(R.array.llx5_playmodes)];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[getIndex(R.array.llx5_playmodes)];
              switch (currentIndex) {
              case 0:// 任一-直选
                   redMin = 1;
                   break;
              case 1:// 任二-直选
                   redMin = 2;
                   break;
              case 2:// 任三-直选
                   redMin = 3;
                   break;
              case 3:// 任四-直选
                   redMin = 4;
                   break;
              case 4:// 任五-直选
                   redMin = 5;
                   break;
              case 5:// 任六-直选
                   redMin = 6;
                   break;
              case 6:// 任七-直选
                   redMin = 7;
                   break;
              case 7:// 任八-直选
                   redMin = 8;
                   break;
              case 8:// 前二-直选
                   redMin = 2;
                   break;
              case 9:// 前二-组选
                   redMin = 2;
                   break;
              case 10:// 前三-直选
                   redMin = 3;
                   break;
              case 11:// 前三-组选
                   redMin = 3;
                   break;
    
              }
         }
    
         @Override
         public String canSelecteRed(int[] selected, int index) {
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 任一-直选
                   break;
              case 1:// 任二-直选
                   break;
              case 2:// 任三-直选
                   break;
              case 3:// 任四-直选
                   break;
              case 4:// 任五-直选
                   break;
              case 5:// 任六-直选
                   break;
              case 6:// 任七-直选
                   break;
              case 7:// 任八-直选
                   if(selected.length>=8){
                        return "最多只能选8个号码!";
                   }
                   break;
              case 8:// 前二-直选
                   if (index / column == 0) {
                        for (int i = 0; i < selected.length; i++) {
                             if (selected[i] == index + column) {
                                  return "前二选号:各位不能重复";
                             }
                        }
                   } else if (index / column == 1) {
                        for (int i = 0; i < selected.length; i++) {
                             if (selected[i] == index - column) {
                                  return "前二选号:各位不能重复";
                             }
                        }
                   }
    
                   break;
              case 9:// 前二-组选
                   break;
              case 10:// 前三-直选
    
                   if (index / column == 0) {
                        for (int i = 0; i < selected.length; i++) {
                             if (selected[i] == index + column
                                       || selected[i] == index + 2 * column) {
                                  return "前三选号:各位不能重复";
                             }
                        }
                   } else if (index / column == 1) {
                        for (int i = 0; i < selected.length; i++) {
                             if (selected[i] == index - column
                                       || selected[i] == index + column) {
                                  return "前三选号:各位不能重复";
                             }
                        }
                   } else if (index / column == 2) {
                        for (int i = 0; i < selected.length; i++) {
                             if (selected[i] == index - column
                                       || selected[i] == index - 2 * column) {
                                  return "前三选号:各位不能重复";
                             }
                        }
                   }
                   break;
              case 11:// 前三-组选
                   break;
    
              }
              return "yes";
         }
    
         public int[][] zhixuanrenyi(int[] selected, int index) {
              int[][] state = new int[2][];
              int[] remove = selected;
              int[] add = new int[] { index };
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         public int[][] zhixuan(int[] selected, int index) {
              int[][] state = new int[2][];
              int[] remove = null;
              int[] add = new int[] { index };
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         public int[][] zuxuan(int[] selected, int index) {
              int[][] state = new int[2][];
              int[] remove = null;
              int[] add = new int[] { index };
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int n = getIndex(R.array.llx5_playmodes);
              switch (n) {
              case 0:
                   return zhixuanrenyi(selected, index);
              case 1:
                   return zhixuan(selected, index);
              case 2:
                   return zhixuan(selected, index);
              case 3:
                   return zhixuan(selected, index);
              case 4:
                   return zhixuan(selected, index);
              case 5:
                   return zhixuan(selected, index);
              case 6:
                   return zhixuan(selected, index);
              case 7:
                   return zhixuan(selected, index);
              case 8:
                   return zhixuan(selected, index);
              case 9:
                   return zuxuan(selected, index);
              case 10:
                   return zhixuan(selected, index);
              case 11:
                   return zuxuan(selected, index);
    
              }
    
              return null;
         }
    
         @Override
         public String formatSelectedRed(String[] text, int[] index) {
              int n = getIndex(R.array.llx5_playmodes);
              switch (n) {
              case 0:
                   return format(text, index);
              case 1:
                   return format(text, index);
              case 2:
                   return format(text, index);
              case 3:
                   return format(text, index);
              case 4:
                   return format(text, index);
              case 5:
                   return format(text, index);
              case 6:
                   return format(text, index);
              case 7:
                   return format(text, index);
              case 8:
                   return format(text, index, 2);
              case 9:
                   return format(text, index);
              case 10:
                   return format(text, index, 3);
              case 11:
                   return format(text, index);
              }
    
              return null;
         }
    
         // 与行号无关 格式化为{2,3,4,5,6}
         public String format(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < text.length; i++) {
                   stringBuffer.append(text[i]);
                   if (i < text.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         // 与行号有关 格式化为{2 3 4,11 15}
         public String format(String[] text, int[] index, int count) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < count; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j] + ",");
                        }
                   }
                   if (stringBuffer.lastIndexOf(",") > -1)
                        stringBuffer.deleteCharAt(stringBuffer.lastIndexOf(","));
                   if (i != count - 1)
                        stringBuffer.append("|");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              lotteryCartItem.mode = currentMode;
              lotteryCartItem.number = redpool;
              if (count == 1) {
                   lotteryCartItem.mode += "单";
              } else {
                   lotteryCartItem.mode += "复";
              }
              lotteryCartItem.mode = currentType + lotteryCartItem.mode;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("任一直选单".equals(mode)) {
                   return 101;
              } else if ("任一直选复".equals(mode)) {
                   return 102;
              } else if ("任二直选单".equals(mode)) {
                   return 103;
              } else if ("任二直选复".equals(mode)) {
                   return 104;
              } else if ("任三直选单".equals(mode)) {
                   return 105;
              } else if ("任三直选复".equals(mode)) {
                   return 106;
              } else if ("任四直选单".equals(mode)) {
                   return 107;
              } else if ("任四直选复".equals(mode)) {
                   return 108;
              } else if ("任五直选单".equals(mode)) {
                   return 109;
              } else if ("任五直选复".equals(mode)) {
                   return 110;
              } else if ("任六直选单".equals(mode)) {
                   return 111;
              } else if ("任六直选复".equals(mode)) {
                   return 112;
              } else if ("任七直选单".equals(mode)) {
                   return 113;
              } else if ("任七直选复".equals(mode)) {
                   return 114;
              } else if ("任八直选单".equals(mode)) {
                   return 115;
              } else if ("任八直选复".equals(mode)) {
                   return 116;
              } else if ("前二直选单".equals(mode)) {
                   return 117;
              } else if ("前二直选复".equals(mode)) {
                   return 118;
              } else if ("前三直选单".equals(mode)) {
                   return 119;
              } else if ("前三直选复".equals(mode)) {
                   return 120;
              } else if ("前二组选单".equals(mode)) {
                   return 121;
              } else if ("前二组选复".equals(mode)) {
                   return 122;
              } else if ("前三组选单".equals(mode)) {
                   return 123;
              } else if ("前三组选复".equals(mode)) {
                   return 124;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 22选5
    */
    public class Lottery22x5 extends LotteryRed {
         public Lottery22x5() {
              icon = R.string.zzx5_icon;
              name = getString(R.string.zzx5_name);
              gameName = getString(R.string.zzx5_game_name);
              code = getString(R.string.zzx5_code);
              issue = getString(R.string.zzx5_issue);
              summary = getString(R.string.zzx5_summary);
              price = getInteger(R.integer.zzx5_price);
              deadLine = getString(R.string.zzx5_deadline);
              redTag = getString(R.string.zzx5_redtag);
              buleTag = getString(R.string.zzx5_bluetag);
              redMin = getInteger(R.integer.zzx5_redmin);
              blueMin = getInteger(R.integer.zzx5_bluemin);
              rules = getStringArray(R.array.zzx5_rules);
              notices = getStringArray(R.array.zzx5_notices);
              playType = getStringArray(R.array.zzx5_playtypes);
              currentType = getString(R.string.zzx5_defaulttype);
              playMode = getStringArray(R.array.zzx5_playmodes);
              currentMode = getString(R.string.zzx5_defaultmode);
              allowAddTo = getBoolean(R.integer.zzx5_allowAdd);
              format = getBoolean(R.integer.zzx5_format);
              officialrule = R.string.zzx5_officialrule;
              prizeexplain = R.string.zzx5_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              return CalculatorUtils.calculatorCombination(red.length, redMin);
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][5];
              for (int i = 0; i < n; i++) {
                   result[i] = CalculatorUtils.getRandomArrayNumber(5, 1, 25);
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              int[] temp;
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   temp = CalculatorUtils.getRandomArrayNumber(5, 1, 25);
                   for (int j = 0; j < 5; j++) {
                        sBuffer.append(StringUtil.format(temp[j]) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public int[] getRandomRed() {
              return CalculatorUtils.getRandomArrayNumber(redMin, 0, 21);
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.zzx5_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              if (red.length >= redMin) {
                   return true;
              }
              return false;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.zzx5_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.zzx5_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.zzx5_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancle) {
              if (isCancle) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < texts.length; i++) {
                   stringBuffer.append(texts[i]);
                   if (i != texts.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              if (count == 1) {
                   lotteryCartItem.mode = "单式";
              } else {
                   lotteryCartItem.mode = "复式";
              }
              lotteryCartItem.number = redpool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 福彩3D
    *
    * @author dzb
    *
    */
    public class Lottery3D extends LotteryRed {
    
         private final int TOTAL = 3; // 单注选号数
         private final int START = 0; // 选号起始数
         private final int END = 9; // 选号终止数
    
         public Lottery3D() {
              icon = R.string.fc3d_icon;
              name = getString(R.string.fc3d_name);
              gameName = getString(R.string.fc3d_game_name);
              code = getString(R.string.fc3d_code);
              issue = getString(R.string.fc3d_issue);
              summary = getString(R.string.fc3d_summary);
              price = getInteger(R.integer.fc3d_price);
              deadLine = getString(R.string.fc3d_deadline);
              redTag = getString(R.string.fc3d_redtag);
              buleTag = getString(R.string.fc3d_bluetag);
              redMin = getInteger(R.integer.fc3d_redmin);
              blueMin = getInteger(R.integer.fc3d_bluemin);
              rules = getStringArray(R.array.fc3d_rules);
              notices = getStringArray(R.array.fc3d_notices);
              playType = getStringArray(R.array.fc3d_playtypes);
              currentType = getString(R.string.fc3d_defaulttype);
              playMode = getStringArray(R.array.fc3d_playmodes);
              currentMode = getString(R.string.fc3d_defaultmode);
              allowAddTo = getBoolean(R.integer.fc3d_allowAdd);
              format = getBoolean(R.integer.fc3d_format);
              officialrule = R.string.fc3d_officialrule;
              prizeexplain = R.string.fc3d_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         /**
         * 计算直选_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zxhz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = 0; j < column; j++) {
                        for (int h = 0; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组三_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zshz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = i; j < column; j++) {
                        if (j == i) {
                             continue;
                        }
                        if (2 * i + j == sum) {
                             count++;
                        }
                        if (2 * j + i == sum) {
                             count++;
                        }
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组六_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zlhz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = i + 1; j < column; j++) {
                        for (int h = j + 1; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
                   }
              }
              return count;
    
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   return CalculatorUtils.calculatorBoxs(red, getRedColumnCount());
              case 1:// 直选-和值
                   return calculatorBoxes_zxhz(getRedColumnCount(), red[0] + 1);
              case 2:// 组三-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 3:// 组三-和值 组三最小{0,0,1} 为1
                   return calculatorBoxes_zshz(getRedColumnCount(), red[0] + 1);
              case 4:// 组六-复式
                   return CalculatorUtils.calculatorCombination(red.length, redMin);
              case 5:// 组六-和值 组三最小{0,1,2} 为3
                   return calculatorBoxes_zlhz(getRedColumnCount(), red[0] + 3);
              }
              return 0;
         }
    
         @Override
         public int[][] getRandom(int n) {
              if (n < 1) {
                   n = 1;
              }
              int[][] result = new int[n][3];
              for (int i = 0; i < n; i++) {
                   result[i] = CalculatorUtils.getRandomArrayNumber(TOTAL, START, END);
              }
    
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              if (n < 1) {
                   n = 1;
              }
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              int[] temp;
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   temp = CalculatorUtils.getRandomArrayNumber(3, 0, 9);
                   for (int j = 0; j < temp.length; j++) {
                        sBuffer.append(temp[j] + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public int[] getRandomRed() {
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
                   int[] red = new int[3];
                   for (int i = 0; i < red.length; i++) {
                        red[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
                   }
                   return red;
              case 1:// 直选-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 27);
              case 2:// 组三-复式
                   return CalculatorUtils.getRandomArrayNumber(2, 0, 9);
              case 3:// 组三-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 25);
              case 4:// 组六-复式
                   return CalculatorUtils.getRandomArrayNumber(3, 0, 9);
              case 5:// 组六-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 21);
    
              }
              return null;
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.fc3d_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0) {
                   return false;
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   if (red[red.length - 1] / getRedColumnCount() != 2)
                        return false;
              case 1:// 直选-单式
                   break;
              case 2:// 组三-复式
                   break;
              case 3:// 组三-和值
                   break;
              case 4:// 组六-复式
                   break;
              case 5:// 组六-和值
                   break;
              }
              if (red.length < redMin) {
                   return false;
              }
              return true;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.fc3d_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              playMode = getPlayModes(R.array.fc3d_playmodes);
              currentMode = playMode[0];
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.fc3d_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
    
              switch (currentIndex) {
              case 0:// 直选-复式
                   redMin = 3;
                   break;
              case 1:// 直选-和值
                   redMin = 1;
                   break;
              case 2:// 组三-复式
                   redMin = 2;
                   break;
              case 3:// 组三-和值
                   redMin = 1;
                   break;
              case 4:// 组六-复式
                   redMin = 3;
                   break;
              case 5:// 组六-和值
                   redMin = 1;
                   break;
              }
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.fc3d_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] selected, int index) {
              return "yes";
         }
    
         public int[][] fushi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = null;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         public int[][] hezhi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = a;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   return fushi(selected, index);
              case 1:// 直选-和值
                   return hezhi(selected, index);
              case 2:// 组三-复式
                   return fushi(selected, index);
              case 3:// 组三-和值
                   return hezhi(selected, index);
              case 4:// 组六-复式
                   return fushi(selected, index);
              case 5:// 组六-和值
                   return hezhi(selected, index);
              }
              return null;
    
         }
    
         @Override
         public String formatSelectedRed(String[] text, int[] indexs) {
              switch (currentIndex) {
              case 0:// 直选-复式
                   return format(text, indexs, 3);
              case 1:// 直选-和值
                   return format(text, indexs);
              case 2:// 组三-复式
                   return format(text, indexs);
              case 3:// 组三-和值
                   return format(text, indexs);
              case 4:// 组六-复式
                   return format(text, indexs);
              case 5:// 组六-和值
                   return format(text, indexs);
              }
              return null;
         }
    
         // 与行号有关 格式化为{2 3 4,11 15}
         private String format(String[] text, int[] index, int count) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < count; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != count - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         // 与行号无关 格式化为{2,3,4,5,6}
         public String format(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < text.length; i++) {
                   stringBuffer.append(text[i]);
                   if (i < text.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              lotteryCartItem.mode = currentMode;
              if (lotteryCartItem.mode.equals("复式")) {
                   if (count == 1) {
                        lotteryCartItem.mode = "单式";
                   }
              }
              lotteryCartItem.mode = currentType + lotteryCartItem.mode;
              lotteryCartItem.number = redpool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("直选单式".equals(mode)) {
                   return 201;
              } else if ("直选复式".equals(mode)) {
                   return 202;
              } else if ("直选和值".equals(mode)) {
                   return 204;
              } else if ("组三复式".equals(mode)) {
                   return 203;
              } else if ("组六单式".equals(mode)) {
                   return 205;
              } else if ("组六复式".equals(mode)) {
                   return 206;
              } else if ("组三和值".equals(mode)) {
                   return 207;
              } else if ("组六和值".equals(mode)) {
                   return 208;
              } else if (StringUtil.isEmpty(mode)) {
                   return 201;
              }
              return 201;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 大乐透
    */
    public class LotteryDLT extends LotteryBase {
         public LotteryDLT() {
              icon = R.string.dlt_icon;
              name = getString(R.string.dlt_name);
              gameName = getString(R.string.dlt_game_name);
              code = getString(R.string.dlt_code);
              issue = getString(R.string.dlt_issue);
              summary = getString(R.string.dlt_summary);
              price = getInteger(R.integer.dlt_price);
              deadLine = getString(R.string.dlt_deadline);
              redTag = getString(R.string.dlt_redtag);
              buleTag = getString(R.string.dlt_bluetag);
              redMin = getInteger(R.integer.dlt_redmin);
              blueMin = getInteger(R.integer.dlt_bluemin);
              rules = getStringArray(R.array.dlt_rules);
              notices = getStringArray(R.array.dlt_notices);
              playType = getStringArray(R.array.dlt_playtypes);
              currentType = getString(R.string.dlt_defaulttype);
              playMode = getStringArray(R.array.dlt_playmodes);
              currentMode = getString(R.string.dlt_defaultmode);
              allowAddTo = getBoolean(R.integer.dlt_allowAdd);
              format = getBoolean(R.integer.dlt_format);
              officialrule = R.string.dlt_officialrule;
              prizeexplain = R.string.dlt_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              long rednum = CalculatorUtils.calculatorCombination(red.length, redMin);
              long bluenum = CalculatorUtils.calculatorCombination(blue.length,
                        blueMin);
              return rednum * bluenum;
         }
    
         @Override
         public int[] getBluePool() {
              return super.getBluePool(R.array.dlt_bluepools);
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][7];
              for (int i = 0; i < n; i++) {
                   result[i] = combineArray(
                             CalculatorUtils.getRandomArrayNumber(5, 1, 35),
                             CalculatorUtils.getRandomArrayNumber(2, 1, 12));
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              if (n < 1) {
                   n = 1;
              }
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              int[] temp;
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   //随机红球
                   temp = CalculatorUtils.getRandomArrayNumber(5, 1,35);
                   for(int red = 0; red < 5; red++) {
                        sBuffer.append(StringUtil.format(temp[red]) + ",");
                   }
                   sBuffer.deleteCharAt(sBuffer.lastIndexOf(","));
                   sBuffer.append("|");
                   //随机蓝球
                   temp = CalculatorUtils.getRandomArrayNumber(2, 1, 12);
                   for(int blue = 0; blue < 2; blue++) {
                        sBuffer.append(StringUtil.format(temp[blue]) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
    
    
              return result;
         }
    
         @Override
         public int[] getRandomBlue() {
              return CalculatorUtils.getRandomArrayNumber(blueMin, 0, 11);
         }
    
         @Override
         public int[] getRandomRed() {
              return CalculatorUtils.getRandomArrayNumber(redMin, 0, 34);
         }
    
         /**
         * 合并红球和蓝球到一个数组
         *
         * @param red
         * @param blue
         * @return
         */
         private int[] combineArray(int[] red, int[] blue) {
              int redLen = red.length;
              int blueLen = blue.length;
              int[] result = new int[red.length + blueLen];
              int n = 0;
              for (n = 0; n < redLen; n++) {
                   result[n] = red[n];
              }
              for (int i = 0; i < blueLen; i++) {
                   result[n++] = blue[i];
              }
    
              return result;
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.dlt_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0 || bule.length == 0) {
                   return false;
              }
              if (red.length >= redMin && bule.length >= blueMin) {
                   return true;
              }
              return false;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.dlt_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.dlt_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.dlt_redpools);
         }
    
         @Override
         public int getBlueColumnCount() {
              return super.getBlueColumnCount(R.array.dlt_bluepools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public String canSelecteBlue(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public int[][] newblueBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < texts.length; i++) {
                   stringBuffer.append(texts[i]);
                   if (i != texts.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public String formatSelectedBlue(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < texts.length; i++) {
                   stringBuffer.append(texts[i]);
                   if (i != texts.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              if (zhuijia) {
                   lotteryCartItem.mode = "追加";
              } else {
                   lotteryCartItem.mode = "";
              }
              if (count == 1) {
                   lotteryCartItem.mode += "单式";
              } else {
                   lotteryCartItem.mode += "复式";
              }
    
              lotteryCartItem.number = redpool + "|" + bluepool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if ("追加单式".equals(mode)||"追加单".equals(mode)) {
                   return 103;
              } else if ("追加复式".equals(mode)) {
                   return 104;
              }else if ("追加".equals(mode)) {
                   return 101;
              }
              else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    
    package cn.com.soarmobile.lottery;
    
    import java.lang.reflect.Constructor;
    import java.lang.reflect.InvocationTargetException;
    import java.util.HashMap;
    import java.util.Map;
    
    import cn.com.soarmobile.SoarEngine;
    
    public class LotteryFactory {
         static Map<Class<?>, LotteryBase> lotterys = new HashMap<Class<?>, LotteryBase>();
         static LotteryBase currentLottery;
         private static LotteryFootSFC sfcLottery;
    
         public static LotteryFootSFC getSFCLottery() {
              if (sfcLottery == null) {
                   sfcLottery = new LotteryFootSFC();
              }
              return sfcLottery;
         }
    
         public static LotteryBase getCurrentLottery() {
              return currentLottery;
         }
    
         public static <T extends LotteryBase> void setCurrentLottery(
                   Class<T> lotteryClass) {
              LotteryFactory.currentLottery = createLottery(lotteryClass);
    
              // 彩种切换时清空购物车 重设奖期信息
              SoarEngine.getInstance().lotteryCart.clear();
              currentLottery.issue = null;
              currentLottery.deadLine =null;
         }
    
         private static <T extends LotteryBase> LotteryBase createLottery(
                   Class<T> lotteryClass) {
              LotteryBase lottery = null;
              if (lotterys.get(lotteryClass) == null) {
                   try {
                        Constructor<T> constructor = lotteryClass
                                  .getConstructor(new Class[] {});
                        lottery = constructor.newInstance();
                        lotterys.put(lotteryClass, lottery);
                   } catch (SecurityException e) {
                        lottery = null;
                        e.printStackTrace();
                   } catch (NoSuchMethodException e) {
                        lottery = null;
                        e.printStackTrace();
                   } catch (IllegalArgumentException e) {
                        lottery = null;
                        e.printStackTrace();
                   } catch (InstantiationException e) {
                        lottery = null;
                        e.printStackTrace();
                   } catch (IllegalAccessException e) {
                        lottery = null;
                        e.printStackTrace();
                   } catch (InvocationTargetException e) {
                        lottery = null;
                        e.printStackTrace();
                   }
              } else {
                   lottery = lotterys.get(lotteryClass);
              }
              return lottery;
         }
    }
    
    
    package cn.com.soarmobile.lottery;
    
    /**
    * 排列三
    */
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    public class LotteryPLS extends LotteryRed {
         public LotteryPLS() {
              icon = R.string.pls_icon;
              name = getString(R.string.pls_name);
              gameName = getString(R.string.pls_game_name);
              code = getString(R.string.pls_code);
              issue = getString(R.string.pls_issue);
              summary = getString(R.string.pls_summary);
              price = getInteger(R.integer.pls_price);
              deadLine = getString(R.string.pls_deadline);
              redTag = getString(R.string.pls_redtag);
              buleTag = getString(R.string.pls_bluetag);
              redMin = getInteger(R.integer.pls_redmin);
              blueMin = getInteger(R.integer.pls_bluemin);
              rules = getStringArray(R.array.pls_rules);
              notices = getStringArray(R.array.pls_notices);
              playType = getStringArray(R.array.pls_playtypes);
              currentType = getString(R.string.pls_defaulttype);
              playMode = getStringArray(R.array.pls_playmodes);
              currentMode = getString(R.string.pls_defaultmode);
              allowAddTo = getBoolean(R.integer.pls_allowAdd);
              format = getBoolean(R.integer.pls_format);
              officialrule = R.string.pls_officialrule;
              prizeexplain = R.string.plw_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.pls_redpools);
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.fc3d_redpools);
         }
    
         @Override
         public int[] getRandomRed() {
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
                   int[] red = new int[3];
                   for (int i = 0; i < red.length; i++) {
                        red[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
                   }
                   return red;
              case 1:// 直选-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 25);
              case 2:// 组三-复式
                   return CalculatorUtils.getRandomArrayNumber(2, 0, 9);
              case 3:// 组三-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 25);
              case 4:// 组六-复式
                   return CalculatorUtils.getRandomArrayNumber(3, 0, 9);
              case 5:// 组六-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 21);
              }
              return null;
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][3];
              for (int i = 0; i < n; i++) {
                   result[i][0] = CalculatorUtils.getRandomNumber(0, 9);
                   result[i][1] = CalculatorUtils.getRandomNumber(0, 9);
                   result[i][2] = CalculatorUtils.getRandomNumber(0, 9);
              }
    
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   for (int j = 0; j < 3; j++) {
                        sBuffer.append(CalculatorUtils.getRandomNumber(0, 9) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              if (red.length < redMin)
                   return false;
              return true;
         }
    
         /**
         * 计算直选_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zxhz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = 0; j < column; j++) {
                        for (int h = 0; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组三_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zshz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = i; j < column; j++) {
                        if (j == i) {
                             continue;
                        }
                        if (2 * i + j == sum) {
                             count++;
                        }
                        if (2 * j + i == sum) {
                             count++;
                        }
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组六_和值情况下的注数
         *
         * @param column
         * @param sum
         * @return
         */
         private int calculatorBoxes_zlhz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = i + 1; j < column; j++) {
                        for (int h = j + 1; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
                   }
              }
              return count;
    
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   return CalculatorUtils.calculatorBoxs(red, getRedColumnCount());
              case 1:// 直选-和值
                   return calculatorBoxes_zxhz(getRedColumnCount(), red[0] + 1);
              case 2:// 组三-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 3:// 组三-和值 组三最小{0,0,1} 为1
                   return 2 * calculatorBoxes_zshz(getRedColumnCount(), red[0] + 1);
              case 4:// 组六-复式
                   return CalculatorUtils.calculatorCombination(red.length, redMin);
              case 5:// 组六-和值 组三最小{0,1,2} 为3
                   return calculatorBoxes_zlhz(getRedColumnCount(), red[0] + 3);
              }
              return 0;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.pls_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              playMode = getPlayModes(R.array.pls_playmodes);
              currentMode = playMode[0];
              notifyPlayModeChanged();
    
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.pls_playmodes);
              if (currentIndex == 3)
                   currentIndex++;
    
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
              switch (currentIndex) {
              case 0:// 直选-单式
                   redMin = 3;
                   break;
              case 1:// 直选-和值
                   redMin = 1;
                   break;
              case 2:// 组三-复式
                   redMin = 2;
                   break;
              case 3:// 组三-和值
                   redMin = 1;
                   break;
              case 4:// 组六-复式
                   redMin = 3;
                   break;
              case 5:// 组六-和值
                   redMin = 1;
                   break;
              }
    
         }
    
         @Override
         public String canSelecteRed(int[] selected, int index) {
              return "yes";
         }
    
         public int[][] fushi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = null;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         public int[][] hezhi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = a;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   return fushi(selected, index);
              case 1:// 直选-和值
                   return hezhi(selected, index);
              case 2:// 组三-复式
                   return fushi(selected, index);
              case 3:// 组三-和值
                   return hezhi(selected, index);
              case 4:// 组六-复式
                   return fushi(selected, index);
              case 5:// 组六-和值
                   return hezhi(selected, index);
              }
              return null;
         }
    
         @Override
         public String formatSelectedRed(String[] text, int[] indexs) {
              switch (currentIndex) {
              case 0:// 直选-复式
                   return format(text, indexs, 3);
              case 1:// 直选-和值
                   return format(text, indexs);
              case 2:// 组三-复式
                   return format(text, indexs);
              case 3:// 组三-和值
                   return format(text, indexs);
              case 4:// 组六-复式
                   return format(text, indexs);
              case 5:// 组六-和值
                   return format(text, indexs);
              }
              return null;
         }
    
         // 与行号有关 格式化为{2 3 4,11 15}
         private String format(String[] text, int[] index, int count) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < count; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != count - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         // 与行号无关 格式化为{2,3,4,5,6}
         public String format(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < text.length; i++) {
                   stringBuffer.append(text[i]);
                   if (i < text.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              lotteryCartItem.number = redpool;
              lotteryCartItem.mode = currentMode;
              if (lotteryCartItem.mode.equals("复式")) {
                   if (count == 1) {
                        lotteryCartItem.mode = "单式";
                   }
              }
              lotteryCartItem.mode = currentType + lotteryCartItem.mode;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("直选单式".equals(mode)) {
                   return 201;
              } else if ("直选复式".equals(mode)) {
                   return 202;
              } else if ("直选和值".equals(mode)) {
                   return 204;
              } else if ("组三复式".equals(mode)) {
                   return 203;
              } else if ("组六单式".equals(mode)) {
                   return 205;
              } else if ("组六复式".equals(mode)) {
                   return 206;
              } else if ("组三和值".equals(mode)) {
                   return 207;
              } else if ("组六和值".equals(mode)) {
                   return 208;
              } else if (StringUtil.isEmpty(mode)) {
                   return 201;
              }
              return 201;
         }
    
    }
    
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 排列五
    */
    public class LotteryPLW extends LotteryRed {
         public LotteryPLW() {
              icon = R.string.plw_icon;
              name = getString(R.string.plw_name);
              gameName = getString(R.string.plw_game_name);
              code = getString(R.string.plw_code);
              issue = getString(R.string.plw_issue);
              summary = getString(R.string.plw_summary);
              price = getInteger(R.integer.plw_price);
              deadLine = getString(R.string.plw_deadline);
              redTag = getString(R.string.plw_redtag);
              buleTag = getString(R.string.plw_bluetag);
              redMin = getInteger(R.integer.plw_redmin);
              blueMin = getInteger(R.integer.plw_bluemin);
              rules = getStringArray(R.array.plw_rules);
              notices = getStringArray(R.array.plw_notices);
              playType = getStringArray(R.array.plw_playtypes);
              currentType = getString(R.string.plw_defaulttype);
              playMode = getStringArray(R.array.plw_playmodes);
              currentMode = getString(R.string.plw_defaultmode);
              allowAddTo = getBoolean(R.integer.plw_allowAdd);
              format = getBoolean(R.integer.plw_format);
              officialrule = R.string.plw_officialrule;
              prizeexplain = R.string.plw_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              int column = getRedColumnCount();
              int m = 0;
              int n = 0;
              int k = 0;
              int j = 0;
              int l = 0;
              for (int i = 0; i < red.length; i++) {
                   if (red[i] >= 0 && red[i] < column) {
                        m++;
                   } else if (red[i] >= column && red[i] < 2 * column) {
                        n++;
                   } else if (red[i] >= 2 * column && red[i] < 3 * column) {
                        k++;
                   } else if (red[i] >= 3 * column && red[i] < 4 * column) {
                        j++;
                   } else if (red[i] >= 4 * column && red[i] < 5 * column) {
                        l++;
                   }
              }
              return m * n * k * j * l;
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][5];
              for (int i = 0; i < n; i++) {
                   for (int j = 0; j < 5; j++) {
                        result[i][j] = CalculatorUtils.getRandomNumber(0, 9);
                   }
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   for (int j = 0; j < 5; j++) {
                        sBuffer.append(CalculatorUtils.getRandomNumber(0, 9) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public int[] getRandomRed() {
              int column = getRedColumnCount();
              int[] red = new int[5];
              for (int i = 0; i < red.length; i++) {
                   red[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
              }
              return red;
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.plw_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              if (red[red.length - 1] / getRedColumnCount() != 4)
                   return false;
              return true;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.plw_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = 0;
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.plw_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < 5; i++) {
                   for (int j = 0; j < indexs.length; j++) {
                        if (indexs[j] / column == i) {
                             stringBuffer.append(texts[j]);
                        }
                   }
                   if (i != 5 - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              if (count == 1) {
                   lotteryCartItem.mode = "单式";
              } else {
                   lotteryCartItem.mode = "复式";
              }
              lotteryCartItem.number = redpool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
    
              return lotteryCartItem;
         }
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 七乐彩
    *
    * @author dzb
    *
    */
    public class LotteryQLC extends LotteryRed {
    
         public LotteryQLC() {
              icon = R.string.qlc_icon;
              name = getString(R.string.qlc_name);
              gameName = getString(R.string.qlc_game_name);
              code = getString(R.string.qlc_code);
              issue = getString(R.string.qlc_issue);
              summary = getString(R.string.qlc_summary);
              price = getInteger(R.integer.qlc_price);
              deadLine = getString(R.string.qlc_deadline);
              redTag = getString(R.string.qlc_redtag);
              buleTag = getString(R.string.qlc_bluetag);
              redMin = getInteger(R.integer.qlc_redmin);
              blueMin = getInteger(R.integer.qlc_bluemin);
              rules = getStringArray(R.array.qlc_rules);
              notices = getStringArray(R.array.qlc_notices);
              playType = getStringArray(R.array.qlc_playtypes);
              currentType = getString(R.string.qlc_defaulttype);
              playMode = getStringArray(R.array.qlc_playmodes);
              currentMode = getString(R.string.qlc_defaultmode);
              allowAddTo = getBoolean(R.integer.qlc_allowAdd);
              format = getBoolean(R.integer.qlc_format);
              officialrule = R.string.qlc_officialrule;
              prizeexplain = R.string.qlc_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.qlc_redpools);
         }
    
         @Override
         public int[] getRandomRed() {
              return CalculatorUtils.getRandomArrayNumber(7, 0, 29);
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][7];
              for (int i = 0; i < n; i++) {
                   result[i] = CalculatorUtils.getRandomArrayNumber(7, 1, 30);
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              int[] temp;
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   temp = CalculatorUtils.getRandomArrayNumber(7, 1, 30);
                   for (int j = 0; j < 7; j++) {
                        sBuffer.append(StringUtil.format(temp[j]) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              if (red.length < redMin)
                   return false;
              return true;
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] bule) {
              if (!isValid(red, bule))
                   return -1;
              return CalculatorUtils.calculatorCombination(red.length, redMin);
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.qlc_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.qlc_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.qlc_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < texts.length; i++) {
                   stringBuffer.append(texts[i]);
                   if (i != texts.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              if (count == 1) {
                   lotteryCartItem.mode = "单式";
              } else {
                   lotteryCartItem.mode = "复式";
              }
              lotteryCartItem.number = redpool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 七星彩
    */
    public class LotteryQXC extends LotteryRed {
         public LotteryQXC() {
              icon = R.string.qxc_icon;
              name = getString(R.string.qxc_name);
              gameName = getString(R.string.qxc_game_name);
              code = getString(R.string.qxc_code);
              issue = getString(R.string.qxc_issue);
              summary = getString(R.string.qxc_summary);
              price = getInteger(R.integer.qxc_price);
              deadLine = getString(R.string.qxc_deadline);
              redTag = getString(R.string.qxc_redtag);
              buleTag = getString(R.string.qxc_bluetag);
              redMin = getInteger(R.integer.qxc_redmin);
              blueMin = getInteger(R.integer.qxc_bluemin);
              rules = getStringArray(R.array.qxc_rules);
              notices = getStringArray(R.array.qxc_notices);
              playType = getStringArray(R.array.qxc_playtypes);
              currentType = getString(R.string.qxc_defaulttype);
              playMode = getStringArray(R.array.qxc_playmodes);
              currentMode = getString(R.string.qxc_defaultmode);
              allowAddTo = getBoolean(R.integer.qxc_allowAdd);
              format = getBoolean(R.integer.qxc_format);
              officialrule = R.string.qxc_officialrule;
              prizeexplain = R.string.qxc_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              int column = getRedColumnCount();
              int m = 0;
              int n = 0;
              int k = 0;
              int j = 0;
              int l = 0;
              int a = 0;
              int b = 0;
              for (int i = 0; i < red.length; i++) {
                   if (red[i] >= 0 && red[i] < column) {
                        m++;
                   } else if (red[i] >= column && red[i] < 2 * column) {
                        n++;
                   } else if (red[i] >= 2 * column && red[i] < 3 * column) {
                        k++;
                   } else if (red[i] >= 3 * column && red[i] < 4 * column) {
                        j++;
                   } else if (red[i] >= 4 * column && red[i] < 5 * column) {
                        l++;
                   } else if (red[i] >= 5 * column && red[i] < 6 * column) {
                        a++;
                   } else if (red[i] >= 6 * column && red[i] < 7 * column) {
                        b++;
                   }
              }
              return m * n * k * j * l * a * b;
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][7];
              for (int i = 0; i < n; i++) {
                   for (int j = 0; j < 7; j++) {
                        result[i][j] = CalculatorUtils.getRandomNumber(0, 9);
                   }
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   for (int j = 0; j < 7; j++) {
                        sBuffer.append(CalculatorUtils.getRandomNumber(0, 9) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public int[] getRandomRed() {
              int column = getRedColumnCount();
              int[] red = new int[7];
              for (int i = 0; i < red.length; i++) {
                   red[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
              }
              return red;
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.qxc_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              if (red[red.length - 1] / getRedColumnCount() != 6)
                   return false;
              return true;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.qxc_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = 0;
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.qxc_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              state[0] = addballs;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < redMin; i++) {
                   for (int j = 0; j < indexs.length; j++) {
                        if (indexs[j] / column == i) {
                             stringBuffer.append(texts[j]);
                        }
                   }
                   if (i != redMin - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              if (count == 1) {
                   lotteryCartItem.mode = "单式";
              } else {
                   lotteryCartItem.mode = "复式";
              }
              lotteryCartItem.number = redpool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 时时乐
    *
    * @author dzb
    *
    */
    public class LotterySSL extends LotteryRed {
    
         public LotterySSL() {
              icon = R.string.ssl_icon;
              name = getString(R.string.ssl_name);
              gameName = getString(R.string.ssl_game_name);
              code = getString(R.string.ssl_code);
              issue = getString(R.string.ssl_issue);
              summary = getString(R.string.ssl_summary);
              price = getInteger(R.integer.ssl_price);
              deadLine = getString(R.string.ssl_deadline);
              redTag = getString(R.string.ssl_redtag);
              buleTag = getString(R.string.ssl_bluetag);
              redMin = getInteger(R.integer.ssl_redmin);
              blueMin = getInteger(R.integer.ssl_bluemin);
              rules = getStringArray(R.array.ssl_rules);
              notices = getStringArray(R.array.ssl_notices);
              playType = getStringArray(R.array.ssl_playtypes);
              currentType = getString(R.string.ssl_defaulttype);
              playMode = getStringArray(R.array.ssl_playmodes);
              currentMode = getString(R.string.ssl_defaultmode);
              allowAddTo = getBoolean(R.integer.ssl_allowAdd);
              format = getBoolean(R.integer.ssl_format);
              officialrule = R.string.ssl_officialrule;
              prizeexplain = R.string.ssl_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         /**
         * 计算直选-和值可组合的注数
         *
         * @param column
         * @param sum
         * @return
         */
         public int calculatorBoxes_zxhz(int column, int sum) {
              int count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = 0; j < column; j++) {
                        for (int h = 0; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
    
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组三-和值可组合的注数
         *
         * @param column
         * @param sum
         * @return
         */
         public int calculatorBoxes_zshz(int column, int sum) {
              int count = 0;
              count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = 0; j < column; j++) {
                        if (i + i + j == sum) {
                             count++;
                        }
    
                   }
              }
              return count;
    
         }
    
         /**
         * 计算组六-和值可组合的注数
         *
         * @param column
         * @param sum
         * @return
         */
         public int calculatorBoxes_zlhz(int column, int sum) {
              int count = 0;
              count = 0;
              for (int i = 0; i < column; i++) {
                   for (int j = 0; j < column; j++) {
                        for (int h = 0; h < column; h++) {
                             if (i + j + h == sum) {
                                  count++;
                             }
                        }
    
                   }
              }
              return count;
    
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] bule) {
              if (!isValid(red, bule))
                   return -1;
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
                   return CalculatorUtils.calculatorBoxs(red, column);
              case 1:// 直选-和值
                   return calculatorBoxes_zxhz(column, red[0]);
              case 2:// 组三-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 3:// 组三-单式
                   return 1;
              case 4:// 组三-和值
                   return calculatorBoxes_zshz(column, red[0]+1);
              case 5:// 组六-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 6:// 组六-和值
                   return calculatorBoxes_zlhz(column, red[0]+3);
              case 7:// 前二-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 8:// 后二-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 9:// 前一-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              case 10:// 后一-复式
                   return 2 * CalculatorUtils
                             .calculatorCombination(red.length, redMin);
              }
              return 0;
         }
    
         @Override
         public int[][] getRandom(int n) {
              redMin = 3;
              int[][] result = new int[n][3];
              for (int i = 0; i < n; i++) {
                   result[i][0] = CalculatorUtils.getRandomNumber(0, 9);
                   result[i][1] = CalculatorUtils.getRandomNumber(0, 9);
                   result[i][2] = CalculatorUtils.getRandomNumber(0, 9);
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   for (int j = 0; j < 3; j++) {
                        sBuffer.append(CalculatorUtils.getRandomNumber(0, 9) + ",");
                   }
                   result[i] = sBuffer.toString().substring(0, sBuffer.length() - 1);
              }
              return result;
         }
    
         @Override
         public int[] getRandomRed() {
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
                   int[] ball = new int[3];
                   for (int i = 0; i < ball.length; i++) {
                        ball[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
                   }
                   return ball;
              case 1:// 直选-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 27);
              case 2:// 组三-复式
                   return CalculatorUtils.getRandomArrayNumber(2, 0, 9);
              case 3:// 组三-单式
                   ball = new int[3];
                   ball[0] = CalculatorUtils.getRandomNumber(0, 9);
                   ball[1] = ball[0] + column;
                   do {
                        ball[2] = CalculatorUtils.getRandomNumber(0, 9);
                   } while (ball[2] == ball[0]);
                   ball[2] = ball[2] + 2 * column;
                   return ball;
              case 4://组三-和值
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 25);
              case 5:// 组六-复式
                   return CalculatorUtils.getRandomArrayNumber(3, 0, 9);
              case 6://组六-和值
              return CalculatorUtils.getRandomArrayNumber(1, 0, 21);
              case 7:// 前二-复式
                   ball = new int[2];
                   for (int i = 0; i < ball.length; i++) {
                        ball[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
                   }
                   return ball;
              case 8:// 后二-复式
                   ball = new int[2];
                   for (int i = 0; i < ball.length; i++) {
                        ball[i] = CalculatorUtils.getRandomNumber(0, 9) + i * column;
                   }
                   return ball;
              case 9:// 前一-复式
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 9);
              case 10:// 后一-复式
                   return CalculatorUtils.getRandomArrayNumber(1, 0, 9);
              }
              return null;
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.ssl_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0)
                   return false;
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
                   break;
              case 1:// 直选-和值
                   break;
              case 2:// 组三-复式
                   break;
              case 3:// 组三-单式
                   if (red[red.length - 1] / column != 2)
                        return false;
              case 4:// 组三-和值
                   break;
              case 5:// 组六-复式
                   break;
              case 6:// 组六-和值
                   break;
              case 7:// 前二-复式
                   break;
              case 8:// 后二-复式
                   break;
              case 9:// 前一-复式
                   break;
              case 10:// 后一-复式
                   break;
              }
              if (red.length < redMin)
                   return false;
              return true;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.ssl_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              playMode = getPlayModes(R.array.ssl_playmodes);
              currentMode = playMode[0];
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.ssl_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
              switch (currentIndex) {
              case 0:// 直选-复式
                   redMin = 3;
                   break;
              case 1:// 直选-和值
                   redMin = 1;
                   break;
              case 2:// 组三-复式
                   redMin = 2;
                   break;
              case 3:// 组三-单式
                   redMin = 3;
                   break;
              case 4:// 组三-和值
                   redMin = 1;
                   break;
              case 5:// 组六-复式
                   redMin = 3;
                   break;
              case 6:// 组六-和值
                   redMin = 1;
                   break;
              case 7:// 前二-复式
                   redMin = 2;
              case 8:// 后二-复式
                   redMin = 2;
                   break;
              case 9:// 前一-复式
                   redMin = 1;
                   break;
              case 10:// 后一-复式
                   redMin = 1;
                   break;
              }
    
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getRedColumnCount(R.array.ssl_redpools);
         }
    
         @Override
         public String canSelecteRed(int[] selected, int index) {
              int column = getRedColumnCount();
              switch (currentIndex) {
              case 0:// 直选-复式
              case 1:// 直选-和值
              case 2:// 组三-复式
              case 3:// 组三-单式
                   if (index >= 0 && index < 2 * column) {
                        if (selected.length == 3) {
                             if (selected[2] % column == index % column) {
                                  return "不能重复选择";
                             }
                        }
                   } else {
                        if (selected.length == 2 || selected.length == 3) {
                             if (selected[1] % column == index % column) {
                                  return "不能重复选择";
                             }
    
                        }
                   }
              case 4:// 组三-和值
              case 5:// 组六-复式
              case 6:// 组六-和值
              case 7:// 前二-复式
              case 8:// 后二-复式
              case 9:// 前一-复式
              case 10:// 后一-复式
              }
              return "yes";
         }
    
         // 复式
         public int[][] fushi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = null;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         // 单式
         public int[][] danshi(int[] a, int b) {
              int[][] state = new int[2][];
              int column = getRedColumnCount();
              int index = b / column;
              int[] add = null;
              int[] remove = null;
              if (a.length == 0) {
                   if (index == 0) {
                        add = new int[] { b, b + column };
                        remove = null;
                   } else if (index == 1) {
                        add = new int[] { b, b - column };
                        remove = null;
                   } else if (index == 2) {
                        add = new int[] { b };
                        remove = null;
                   }
              } else if (a.length == 1) {
                   if (index == 0) {
                        add = new int[] { b, b + column };
                        remove = null;
                   } else if (index == 1) {
                        add = new int[] { b, b - column };
                        remove = null;
                   } else if (index == 2) {
                        add = new int[] { b };
                        remove = a;
                   }
              } else if (a.length == 2) {
                   if (index == 0) {
                        add = new int[] { b, b + column };
                        remove = a;
                   } else if (index == 1) {
                        add = new int[] { b, b - column };
                        remove = a;
                   } else if (index == 2) {
                        add = new int[] { b };
                        remove = null;
                   }
    
              } else if (a.length == 3) {
                   if (index == 0) {
                        add = new int[] { b, b + column };
                        remove = new int[] { a[0], a[1] };
                   } else if (index == 1) {
                        add = new int[] { b, b - column };
                        remove = new int[] { a[0], a[1] };
                   } else if (index == 2) {
                        add = new int[] { b };
                        remove = new int[] { a[2] };
                   }
    
              }
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         // 和值
         public int[][] hezhi(int[] a, int b) {
              int[][] state = new int[2][];
              int[] add = new int[] { b };
              int[] remove = a;
              state[0] = add;
              state[1] = remove;
              return state;
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              int column = getRedColumnCount();
              if (isCancel) {
                   if (currentIndex == 3) {
                        if (index / column == 0) {
                             int[][] state = new int[2][];
                             int[] remove = new int[] { index, index + column };
                             int[] add = null;
                             state[0] = add;
                             state[1] = remove;
                             return state;
                        } else if (index / column == 1) {
                             int[][] state = new int[2][];
                             int[] remove = new int[] { index, index - column };
                             int[] add = null;
                             state[0] = add;
                             state[1] = remove;
                             return state;
                        }
                   }
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
    
              }
              switch (currentIndex) {
              case 0:// 直选-复式
                   return fushi(selected, index);
              case 1:// 直选-和值
                   return hezhi(selected, index);
              case 2:// 组三-复式
                   return fushi(selected, index);
              case 3:// 组三-单式
                   return danshi(selected, index);
              case 4:// 组三-和值
                   return hezhi(selected, index);
              case 5:// 组六-复式
                   return fushi(selected, index);
              case 6:// 组六-和值
                   return hezhi(selected, index);
              case 7:// 前二-复式
                   return fushi(selected, index);
              case 8:// 后二-复式
                   return fushi(selected, index);
              case 9:// 前一-复式
                   return fushi(selected, index);
              case 10:// 后一-复式
                   return fushi(selected, index);
              }
              return null;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              switch (currentIndex) {
              case 0:// 直选-复式
                   return format(texts, indexs, 3);
              case 1:// 直选-和值
                   return format(texts, indexs);
              case 2:// 组三-复式
                   return format(texts, indexs);
              case 3:// 组三-单式
                   return format(texts, indexs);
              case 4:// 组三-和值
                   return format(texts, indexs);
              case 5:// 组六-复式
                   return format(texts, indexs);
              case 6:// 组六-和值
                   return format(texts, indexs);
              case 7:// 前二-复式
                   return format_qianer(texts, indexs);
              case 8:// 后二-复式
                   return format_houer(texts, indexs);
              case 9:// 前一-复式
                   return format_qianyi(texts, indexs);
              case 10:// 后一-复式
                   return format_houyi(texts, indexs);
              }
              return null;
         }
    
         // 与行号有关 格式化为{2 3 4,11 15}
         private String format(String[] text, int[] index, int count) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < count; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != count - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         private String format_qianer(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < 2; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != 2 - 1)
                        stringBuffer.append(",");
              }
              stringBuffer.append(",_");
              return stringBuffer.toString();
         }
    
         private String format_houer(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              stringBuffer.append("_,");
              int column = getRedColumnCount();
              for (int i = 0; i < 2; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != 2 - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         private String format_houyi(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              stringBuffer.append("_,");
              stringBuffer.append("_,");
              int column = getRedColumnCount();
              for (int i = 0; i < 1; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != 1 - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         private String format_qianyi(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              int column = getRedColumnCount();
              for (int i = 0; i < 1; i++) {
                   for (int j = 0; j < index.length; j++) {
                        if (index[j] / column == i) {
                             stringBuffer.append(text[j]);
                        }
                   }
                   if (i != 1 - 1)
                        stringBuffer.append(",");
              }
              stringBuffer.append(",_");
              stringBuffer.append(",_");
              return stringBuffer.toString();
         }
    
         // 与行号无关 格式化为{2,3,4,5,6}
         public String format(String[] text, int[] index) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < text.length; i++) {
                   stringBuffer.append(text[i]);
                   if (i < text.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name = gameName;
              lotteryCartItem.number = redpool;
              lotteryCartItem.mode = currentMode;
              if (lotteryCartItem.mode.equals("复式")) {
                   if (count == 1) {
                        lotteryCartItem.mode = "单式";
                   }
              }
              lotteryCartItem.mode = currentType + lotteryCartItem.mode;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("直选单式".equals(mode)) {
                   return 101;
              } else if ("直选复式".equals(mode)) {
                   return 102;
              } else if ("组三单式".equals(mode)) {
                   return 103;
              } else if ("组三复式".equals(mode)) {
                   return 104;
              } else if ("组三和值".equals(mode)) {
                   return 105;
              } else if ("组六单式".equals(mode)) {
                   return 106;
              } else if ("组六复式".equals(mode)) {
                   return 107;
              } else if ("组六和值".equals(mode)) {
                   return 108;
              } else if ("前一单式".equals(mode)) {
                   return 109;
              } else if ("前一复式".equals(mode)) {
                   return 110;
              } else if ("后一单式".equals(mode)) {
                   return 111;
              } else if ("后一复式".equals(mode)) {
                   return 112;
              } else if ("前二单式".equals(mode)) {
                   return 113;
              } else if ("前二复式".equals(mode)) {
                   return 114;
              } else if ("后二单式".equals(mode)) {
                   return 115;
              } else if ("后二复式".equals(mode)) {
                   return 116;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    
    }
    package cn.com.soarmobile.lottery;
    
    import cn.com.soarmobile.R;
    import cn.com.soarmobile.bean.LotteryCartItem;
    import cn.com.soarmobile.util.CalculatorUtils;
    import cn.com.soarmobile.util.StringUtil;
    
    /**
    * 双色球
    */
    public class LotterySSQ extends LotteryBase {
         public LotterySSQ() {
              icon = R.string.ssq_icon;
              name = getString(R.string.ssq_name);
              gameName = getString(R.string.ssq_game_name);
              code = getString(R.string.ssq_code);
              issue = getString(R.string.ssq_issue);
              summary = getString(R.string.ssq_summary);
              price = getInteger(R.integer.ssq_price);
              deadLine = getString(R.string.ssq_deadline);
              redTag = getString(R.string.ssq_redtag);
              buleTag = getString(R.string.ssq_bluetag);
              redMin = getInteger(R.integer.ssq_redmin);
              blueMin = getInteger(R.integer.ssq_bluemin);
              rules = getStringArray(R.array.ssq_rules);
              notices = getStringArray(R.array.ssq_notices);
              playType = getStringArray(R.array.ssq_playtypes);
              currentType = getString(R.string.ssq_defaulttype);
              playMode = getStringArray(R.array.ssq_playmodes);
              currentMode = getString(R.string.ssq_defaultmode);
              allowAddTo = getBoolean(R.integer.ssq_allowAdd);
              format = getBoolean(R.integer.ssq_format);
              officialrule = R.string.ssq_officialrule;
              prizeexplain = R.string.ssq_prizeexplain;
              notifyPlayTypeChanged();
         }
    
         @Override
         public long calculatorBoxes(int[] red, int[] blue) {
              if (!isValid(red, blue)) {
                   return -1;
              }
              long rednum = CalculatorUtils.calculatorCombination(red.length, redMin);
              long bluenum = CalculatorUtils.calculatorCombination(blue.length,
                        blueMin);
              return rednum * bluenum;
         }
    
         @Override
         public int[] getBluePool() {
              return super.getBluePool(R.array.ssq_bluepools);
         }
    
         @Override
         public int[][] getRandom(int n) {
              int[][] result = new int[n][7];
              int[] temp;
              for (int i = 0; i < n; i++) {
                   temp = CalculatorUtils.getRandomArrayNumber(6, 1, 33);
                   for (int j = 0; j < temp.length; j++) {
                        result[i][j] = temp[j];
                   }
                   result[i][6] = CalculatorUtils.getRandomNumber(1, 16);
              }
              return result;
         }
    
         @Override
         public String[] getRandomString(int n) {
              String[] result = new String[n];
              StringBuffer sBuffer = new StringBuffer();
              int[] temp;
              for (int i = 0; i < n; i++) {
                   sBuffer.delete(0, sBuffer.length());
                   // 红球
                   temp = CalculatorUtils.getRandomArrayNumber(6, 1, 33);
                   for (int j = 0; j < 6; j++) {
                        sBuffer.append(StringUtil.format(temp[j]) + ",");
                   }
                   sBuffer.deleteCharAt(sBuffer.lastIndexOf(","));
                   sBuffer.append("#");
                   // 蓝球
                   sBuffer.append(StringUtil.format(CalculatorUtils
                                  .getRandomNumber(1, 16)) + "");
                   result[i] = sBuffer.toString();
              }
              return result;
         }
    
         @Override
         public int[] getRandomBlue() {
              return CalculatorUtils.getRandomArrayNumber(blueMin, 0, 15);
         }
    
         @Override
         public int[] getRandomRed() {
              return CalculatorUtils.getRandomArrayNumber(redMin, 0, 32);
         }
    
         @Override
         public int[] getRedPool() {
              return super.getRedPool(R.array.ssq_redpools);
         }
    
         @Override
         public boolean isValid(int[] red, int[] bule) {
              if (red.length == 0 || bule.length == 0)
                   return false;
              if (red.length >= redMin && bule.length >= blueMin) {
                   return true;
              }
              return false;
         }
    
         @Override
         public void reset(boolean isAutoToManual) {
              currentType = getString(R.string.ssq_defaulttype);
              if (isAutoToManual) {
                   notifyPlayTypeChanged();
              }
         }
    
         @Override
         public void notifyPlayTypeChanged() {
              notifyPlayModeChanged();
         }
    
         @Override
         public void notifyPlayModeChanged() {
              currentIndex = getIndex(R.array.ssq_playmodes);
              if (!StringUtil.isEmpty(rules))
                   currentRule = rules[currentIndex];
              if (!StringUtil.isEmpty(notices))
                   currentNotice = notices[currentIndex];
         }
    
         @Override
         public int getRedColumnCount() {
              return super.getBlueColumnCount(R.array.ssq_redpools);
         }
    
         @Override
         public int getBlueColumnCount() {
              return super.getBlueColumnCount(R.array.ssq_bluepools);
         }
    
         @Override
         public String canSelecteRed(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public String canSelecteBlue(int[] a, int b) {
              return "yes";
         }
    
         @Override
         public int[][] newRedBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              int[] remove = null;
              state[0] = addballs;
              state[1] = remove;
              return state;
         }
    
         @Override
         public int[][] newblueBalls(int[] selected, int index, boolean isCancel) {
              if (isCancel) {
                   int[][] state = new int[2][];
                   int[] remove = new int[] { index };
                   int[] add = null;
                   state[0] = add;
                   state[1] = remove;
                   return state;
              }
              int[][] state = new int[2][];
              int[] addballs = new int[] { index };
              int[] remove = null;
              state[0] = addballs;
              state[1] = remove;
              return state;
         }
    
         @Override
         public String formatSelectedRed(String[] texts, int[] indexs) {
              StringBuffer stringBuffer = new StringBuffer();
              for (int i = 0; i < texts.length; i++) {
                   stringBuffer.append(texts[i]);
                   if (i != texts.length - 1)
                        stringBuffer.append(",");
              }
              return stringBuffer.toString();
         }
    
         @Override
         public String formatSelectedBlue(String[] texts, int[] indexs) {
              return formatSelectedRed(texts, indexs);
         }
    
         @Override
         public LotteryCartItem createLotteryCartItem(String redpool,
                   String bluepool, String result, boolean zhuijia) {
              LotteryCartItem lotteryCartItem = new LotteryCartItem();
              int m = result.indexOf("注");
              int n = result.indexOf("元");
              long count = Long.parseLong(result.substring(0, m));
              long money = Long.parseLong(result.substring(m + 1, n));
              lotteryCartItem.count = count;
              lotteryCartItem.money = money;
              lotteryCartItem.isAddTo = zhuijia;
              lotteryCartItem.name =gameName;
              if (count == 1) {
                   lotteryCartItem.mode = "单式";
              } else {
                   lotteryCartItem.mode = "复式";
              }
              lotteryCartItem.number = redpool + "#" + bluepool;
              lotteryCartItem.type = getTypeCodeByMode(lotteryCartItem.mode) + "";
              return lotteryCartItem;
         }
    
         @Override
         public int getTypeCodeByMode(String mode) {
              if ("单式".equals(mode)) {
                   return 101;
              } else if ("复式".equals(mode)) {
                   return 102;
              } else if (StringUtil.isEmpty(mode)) {
                   return 101;
              }
              return 101;
         }
    }
    
    
    展开全文
  • 写一个彩票程序:307

    千次阅读 2013-10-20 13:32:04
    1. 写一个彩票程序:307。随机(1~30之间)生成7个随机数,注意不能重复。然后从键盘输入7个数,对比7个数是否与随机数有相同的。最后显示“中了几个号”。同时,如果中了7个号,显示一等奖;如果中了6个号,显示...

    1. 写一个彩票程序:307。随机(1~30之间)生成7个随机数,注意不能重复。然后从键盘输入7个数,对比7个数是否与随机数有相同的。最后显示“中了几个号”。同时,如果中了7个号,显示一等奖;如果中了6个号,显示二等奖;如果中了5个号,显示三等奖。要求:首先写出程序的实现思想,特别是程序所使用的数据结构,然后写出Java实现代码。【说明:键盘输入可以使用Scanner类】

    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Scanner;
    public class Lottery {
    	public static void main(String[] args) {
    		Scanner sc=new Scanner(System.in);
    		System.out.print("Please input the range of the random number:");
    		int n=sc.nextInt();//定义生成随机数的范围;
    		System.out.print("Please input the amount of the random number:");
    		int m=sc.nextInt();//定义生成随机数的个数;
    		HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
    		for(int i=0;i<m;i++)
    		{
    			int number=0;
    			do
    			{
    				number=(int)(Math.random()*n)+1;//
    			}while(map.containsKey(number));//如果出现过,继续循环;
    			map.put(number,1);//将number位置的value赋值为1;
    		}
    		System.out.print("Please input your "+m+" number(no repeat):");
    		int flag=0;
    		for(int i=0;i<m;i++)
    		{
    			int number=sc.nextInt();
    			if(map.containsKey(number))//如果number处的value不为空,则表示猜中;
    				flag++;
    		}
    		System.out.print("The random number is:");
    		Iterator<Entry<Integer, Integer>> it=map.entrySet().iterator();
    		while(it.hasNext())//输出随机生成的值,可以没有、、、、、
    		{
    			Map.Entry<Integer, Integer> entry=(Entry<Integer, Integer>) it.next();
    			System.out.print(entry.getKey()+" ");
    		}
    		System.out.println("\nYou guessed "+flag+"!");
    		if(flag==m)
    			System.out.println("Congratulations,you win the first prize!");
    		else if(flag==(m-1))
    			System.out.println("Congratulations,you win the second prize!");
    		else if(flag==(m-2))
    			System.out.println("Congratulations,you win the third prize!");
    		else
    			System.out.println("I`m sorry,you can`t win the prize!");
    	}
    }
    


    展开全文
  • 彩票相关知识

    万次阅读 2012-02-12 09:21:21
    很多人做梦都想中得彩票头奖,很多人希望天上能掉下馅饼来砸中自己,很多人在作白日梦……彩票是一种风险投资,是一种四两拨千斤的气势,更是一种众人拾柴火焰高的真实写照,没买过彩票的人是很难体会那种美好的期望...
  • 阮小二买彩票

    2019-02-16 16:52:49
    元素时,这个“禁令”是错误的。 一个解决方法是统计A[0]~A[cur-1]中P[i]的出现次数c1,以及P数组中P[i]的出现次数 c2。只要c1,就能递归调用。 else for(int i = 0; i ; i++) { int c1 = 0, c2 = 0; for...
  • 彩票基础知识

    千次阅读 2010-04-05 21:15:00
    遗漏可以参看表格分析中的组遗漏分析。单选遗漏可以参看表格分析中的单选遗漏分析。   六:和值与合值 在 3D 中和值与合值是很重要的 2 个术语, 和值表示某些数的...
  • 恒朋无纸化彩票系统数据接入通信协议 深圳市恒朋科技开发有限公司 ShenzhenHelperScience&TechnologyCo.,Ltd. 恒朋无纸化彩票系统数据接入通信协议 文档版本历史 ...
  • 中彩体彩排列3彩票软件 软件大小:3612 KB软件语言:简体中文软件类别:国产软件 / 共享版 / 彩票工具应用平台:Win9x/NT/2000/XP/2003界面预览:插件情况: 投诉更新时间:2007-07-04 13:46:51下载次数:...
  • 3d跨度振幅走势图实现--彩票

    万次阅读 2018-06-05 17:28:21
    initShow:'',/* 是否初始化时显示重号或者其它号码,格式为复选框ID+,号 "c_tb,c_v,c_v3,c_h,c_h3,c_x,c_x3" */ stop_buy_re:/sina|tenpay|paipai|youa/ /* 禁止出现购买按钮的包含站点规则 */ }; ESUNChart.CSS=...
  • 中彩体彩排列3彩票软件 v4.13 build 2007.07.04 软件大小:3612 KB软件语言:简体中文软件类别:国产软件 / 共享版 / 彩票工具应用平台:Win9x/NT/2000/XP/2003界面预览:插件情况: 投诉更新时间:2007-...
  • 这个项目用了8个晚上(20:00-23:00)加上2个白天完成。   一、所用知识点 1、java语言基础 2、多线程 3、Swing控件 ...3、随机号功能 ...6、号有要求产生随机号码 三、Jar包介绍  ...
  • 机选、复选、倍投,还是托胆。。。[[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/47.gif][/img] 程序员工资太低了,根本养不活自己哎。。。 [img=...
  • 响应用户输入 4、完善图形应用程序 ...通过界面我们可以得知每个组件的功能:复选框随机生成会帮主用户随机显示6个数字填入彩票号码中,复选框自己选择则是自己输入彩票号码。过户单击按钮“开始
  • Android 双色球小游戏

    2011-08-13 05:45:50
    这是我写的android的双色球的小游戏,有四个主菜单,开始游戏,设置,帮助,退出,进入开始游戏,还能选择单选模式和复选模式,然后点击开奖,就能讲加过通过彩票图的形式显示出来了!可以在我的博客上看效果图: ...
  • android安卓源码海量项目合集打包-1

    万次阅读 多人点赞 2019-06-11 16:16:24
    │ │ 仿miui对话框,普通对话框,带EditText对话框,列表框,单选框,复选框,等等.rar │ │ 仿QQ的头像选择弹出的对话框,酷似!.zip │ │ 仿照支付宝支付成功的一个简单实例dialog.rar │ │ 各种android弹...
  • 最近每天都会被《哪吒之魔童降世》的票房、评论刷屏,这不今天刚刚新闻报道说是票房已经突破7亿了.....,对于当前国产动漫来说,惊不惊喜意不意外呢?可惜我还没有时间前去看看这部暑期大片呢,这周五有时间的话一定...
  • 软件测试规范

    2019-12-11 15:21:19
    17) 复选框组内是否允许多个复选框(包括全部可选)可选;如果复选框组内无复选框可选,这种情况是否允许存在;文本框及某些控件拒绝输入和选择时显示区域是否变灰或按既定规约处理。 18) 密码输入框是否按掩码的...
  • 戳蓝字“CSDN云计算”关注我们哦!作者 | 刘超本文转载自公众号:刘超的通俗云计算一、我佛造经传极乐 话说我佛如来为度化天下苍生,有三藏真经,可劝人为善。就...
  • WEB入门二 表格和表单

    千次阅读 2017-02-14 13:57:51
    学习内容Ø 表格的作用和制作Ø 表单的制作能力目标Ø 掌握表格的创建Ø 掌握设置表格的常用属性;Ø 理解表单的作用Ø 熟练掌握表单常用元素本章简介表格对于网页制作而言极其重要,其最明显的优点是能够以...
  • 贴出最新整理成数据库的英语谚语大全:1. "After you" is good manners. “您先请”是礼貌。2. A bad beginning makes a bad ending. 不善始者不善终。3. A bad bush is better than the open field....
  • 乐透抽奖模拟

    2018-09-30 16:54:22
    程序演示:输入五个抽奖数(quickpick复选框为快速生成,personal为自己编辑),点击play程序开始,中奖情况统计在下方,默认每周开一次大乐透,drawings表示开奖次数。 源程序包括界面类文件和事件类文件。 ...
  • WEB 测试总结

    2018-11-06 11:45:39
    文章来源:... 目录 1. 登录测试 ...3. 导航条测试 4. 链接测试 5. 快捷键测试 6. 按钮测试 ...10. 复选框测试 11. 日期控件测试 12. 查询结果列表测试 13. 搜索功能测试 14. 图片测试 15....
  • web测试方法总结

    2019-03-18 12:27:00
    目录 1. 登录测试 ...10. 复选框测试 11. 日期控件测试 12. 查询结果列表测试 13. 搜索功能测试 14. 图片测试 15. 静态文字测试 16. 上传文件测试 17. 下载文件测试 18. 界面和易用性测试 1...

空空如也

空空如也

1 2 3 4 5 ... 17
收藏数 330
精华内容 132
关键字:

彩票复选