第六次作业

package xq;

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

public class choujiang {
ArrayList cards;

 public ArrayList<Integer> deal(){
 
	if(cards==null){
		cards = new ArrayList<Integer>(); 
		for(int i =1;i<100;i++){
			cards.add(i);
		}
		
	}
	Collections.shuffle(cards);
	return cards;
}

public void play(){
   Random r = new Random();	
   int a = r.nextInt(100);
   System.out.println("一等奖:"+ cards.get(a)+"号");
   cards.remove(a);
   for(int i=1;i<=3;i++){
	   a = r.nextInt(100);
	  System.out.println("二等奖:"+cards.get(a)+"号");
	  cards.remove(a);
   }
}

public static void main(String[] args) {
choujiang a=new choujiang();
a.deal();
a.play();
}

posted @ 2016-05-12 09:03  青青柠檬味  阅读(94)  评论(0编辑  收藏  举报