第六次作业
package xq;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class choujiang {
ArrayList
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();
}