双色球选号码,自选号码

昨天说好的做个双色球的,但是开奖号码和规则没做
用到的方法:
1.用了set方法去除重复
2.random方法做机选,scanner方法做自选,然后for循环遍历打印选的号码
3.数组区分红球,蓝球

import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;public class kaijiang {int m = 0;// 中了的红球数目int money;// 奖金static int[] red = new int[33];// 红球数组1-33static int[] blue = new int[16];// 蓝球数组1-16static int i = 0;public static void playRules() {// 红球33个System.out.print("红球:{");for (i = 0; i < 33; i++) {red[i] = i + 1;if (i < 32) {System.out.print(red[i] + ",");} else {System.out.print(red[i]);}}System.out.print("}");System.out.println("");System.out.print("蓝球:{");// 蓝球16个for (i = 0; i < 16; i++) {blue[i] = i + 1;if (i < 15) {System.out.print(blue[i] + ",");} else {System.out.print(blue[i]);}}System.out.print("}");System.out.println("");System.out.println("");System.out.println("========游戏规则========");System.out.println("你需要从红球1-33中选取6个号码,从蓝球1-16中选取1个号码");System.out.println("如果中了6个红球和1个篮球就是一等奖,奖金浮动");System.out.println("如果中了6个红球就是二等奖,奖金浮动");System.out.println("如果中了5个红球和1个篮球就是三等奖,奖金3000");System.out.println("如果中了5个红球或者中了4个红球和1个篮球就是四等奖,奖金200");System.out.println("如果中了4个红球或者中了3个红球和1个篮球就是五等奖,奖金10");System.out.println("如果中了1个红球和1个篮球或者1个篮球就是六等奖,奖金5");System.out.println("");}public static void computerChoose() {System.out.println("计算机将从红球1-33中选取6个号码");// 避免重复使用set// 挑选6个数字放入setSet<Integer> set = new HashSet<>();// 随机数采用红球号码while (set.size() < 6) {// int temp=m+(int)(Math.random()*(n+1-m)); //生成从m到n的随机整数[m,n]int num = new Random().nextInt(33 + 1); // 取随机数1-33// 去除重复判断if (!set.contains(num)) {set.add(num);}}// 打印最终红球的机选号码for (Integer integer : set) {System.out.println("机选红球号码为:" + integer);}System.out.println("计算机将从蓝球1-16中选取1个号码");int num2 = new Random().nextInt(16 + 1); // 取随机数1-16System.out.println("机选蓝球号码为:" + num2);}public static void userChoose() {System.out.print("请从红球1-33中选取6个号码");// 避免重复使用setSet<Integer> set = new HashSet<>();// 随机数采用红球号码while (set.size() < 6) {Scanner c = new Scanner(System.in);int num = c.nextInt();if (num > 33 || num < 1) {System.out.println("您的输入有误请重新输入");userChoose();}// 去除重复判断if (!set.contains(num)) {set.add(num);}}// 打印最终红球的机选号码for (Integer integer : set) {System.out.println("你选红球号码为:" + integer);}System.out.println("请从蓝球1-16中选取1个号码");Scanner c = new Scanner(System.in);int num2 = c.nextInt();System.out.println("你选的蓝球号码为:" + num2);if (num2 > 16 || num2 < 1) {System.out.println("您的输入有误请重新输入");userChoose();}}public static void main(String[] args) {playRules();System.out.println("请输入你的选择:");System.out.println("1.机选   2.自选");Scanner co = new Scanner(System.in);int m = co.nextInt();if (m == 1) {computerChoose();} else if (m == 2) {userChoose();}}}