import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class Choujiang {
public ArrayList <Integer> Sumber;
public static void main(String[] args) {
Choujiang g = new Choujiang();
g.deal();
g.display();
// TODO Auto-generated method stub
}
public ArrayList <Integer> deal(){
if(Sumber == null){
Sumber = new ArrayList <Integer>();
for(int i=1; i<=15; i++){
Sumber.add(i);}
}
Collections.shuffle(Sumber);
return (Sumber);
}
public void display(){
Random g = new Random ();
int a = g.nextInt(15);
System.out.println("一等奖:"+Sumber.get(a)+"号");
Sumber.remove(a);
int k=14;
for(int j=1;j<=10;j++){
a = g.nextInt(k);
System.out.println("二等奖:"+Sumber.get(a)+"号");
Sumber.remove(a);
k--;
}
}
}
时间: 2024-10-18 00:27:11