第六次作业 修改期中作业

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Game {
ArrayList choujiang;
public static void main(String[] args) {
// TODO Auto-generated method stub
Game g = new Game();
g.deal();
System.out.println("一等奖获得者:");
g.sj(1);
System.out.println("\n");
System.out.println("二等奖获得者:");
g.sj(5);
System.out.println("\n");
System.out.println("三等奖获得者:");
g.sj(8);
System.out.println("");

}
public void deal(){
	if(choujiang == null){
		choujiang = new ArrayList<Integer>();
		for(int i=1;i<=2000;i++){
			choujiang.add(i);
		}
	}
	Collections.shuffle(choujiang);
}
public void sj(int n){
	Random ran1 = new Random(2000);
    
    for (int i = 0; i < n; i++) {
    	int index = ran1.nextInt(choujiang.size());
        System.out.print(choujiang.get(index)+"\t");
        choujiang.remove(index);
       
    }

}

}

posted @ 2016-05-12 09:52  14软件G1靳晓芳  阅读(87)  评论(0编辑  收藏  举报