/**
* 根据条件生成卡号密码方法
* head 卡号头
* weishu 卡的位数
* num 一次生成卡的数量
*/
public String getPass(String head,int weishu,int num){
for(int i=0;i<num;i++){
System.out.println(this.roadmnum(head, weishu));
}
return null;
}
/**
* 生成规定的n位随机不重复的数
* @param weishu
* @return
*/
public String roadmnum(String head,int weishu){
int roandm=0;
char [] str = {'0','1','2','3','4','5','6','7','8','9'};
// char [] str = {'a',b',c',d',e','f',0','1','2','3','4','5','6','7','8','9'};
StringBuffer pwd = new StringBuffer("");
Random r = new Random();
for(int count = 0;count<weishu;count++){
//生成10以内的随机整数
roandm = Math.abs(r.nextInt(10));
if(roandm>=0 || roandm<str.length){
pwd.append(""+str[roandm]);
}
}
return head+""+pwd.toString();
}
public static void main(String args[]){
spinfo sp = new spinfo();
sp.getPass("BJ",2, 20);
}