package com.lovo.test;

import com.lovo.bean.LotteryMachine;

public class TestMain {

 public static void main(String[] args) {  

    // TODO Auto-generated method stub     

 LotteryMachine lm = new LotteryMachine();   lm.run();

    }

}

 

 

 

package com.lovo.bean;

public class LotteryMachine {  

 private int[] red = new int[6];  

 private int blue;

public void run(){
  this.welcome();
  this.generateRed();
  this.generateBlue();
  this.showResult();
 }

private void welcome(){
  System.out.println("******欢迎使用J124彩票生成器********");
  System.out.println("******************************");
  System.out.println("*******************version1.1**");
  System.out.println("***********祝君好运!!************");
 }

private void generateRed(){
  for(int i = 0; i < this.red.length; i++){
   red[i] = (int)(Math.random() * 33) + 1;
   for(int j = 0; j < i;j++){
    if(red[i] == red[j]){
     i--;
     break;
    }
   }
   
  }
 }

 

private void generateBlue(){
  this.blue = (int)(Math.random() * 16) + 1;
 }
 
 private void showResult(){
  System.out.print("生成的红球是:");
  for(int i = 0; i < this.red.length; i++){
   System.out.print(this.red[i]);
   if(i != this.red.length - 1){
    System.out.print(",");
   }
  }
  System.out.println();
  System.out.println("生成的蓝球是:" + this.blue);
 }

}

 

posted on 2016-05-29 17:46  喵精四哈  阅读(485)  评论(0编辑  收藏  举报