看了狗屁不通文章生成器,我想起自己写过个人信息生成器
程序员文章站
2024-03-12 22:20:26
...
以前学JDBC写的,给数据库写几个测试用户,留到现在,虽然结构servlet结构那时候狗屁不通,但这玩意我很jio傲,单独剪出来分享。
public static String createName() {
String[] firstName= {"赵","钱","孙","李","周","吴","郑","王","冯","陈","卫","蒋","沈","韩","杨",
"朱","秦","尤","许","何","吕","施","张","孔","曹","严","华","金","魏","陶","姜","谢","邹","柏","水","窦","章","云",
"苏","潘","葛","奚","范","彭","郎","鲁","韦","昌","马","苗","凤","花","方","俞","任","袁","柳","鲍","史","唐","费",
"廉","岑","薛","雷","贺","倪","汤","殷","罗","毕","郝","安","常","乐","于","时","傅","齐","康","伍","余","元","顾",
"孟","黄","萧","姚","汪","毛","米","成","戴","谈","宋","庞","纪","项","董","梁","杜","阮","季","贾","江","童","郭",
"盛","林","徐","丘","高","夏","蔡","田","樊","胡","霍","万","卢","莫","丁","邓","洪","包","程","陆","宁","武","刘",
"龙","叶","白","乔","谭","向","曾"};
int firstIndex=(int)(Math.random()*firstName.length);
String[] nextName= {"伟","芳","秀","英","娜","敏","静","丽","勇","强","磊","军","洋","艳","涛",
"志","智","仁","信","明","达","超","杰","兰","夏","霞","平","桂","松","海","瑞","睿","浩","博","昊","悦","妍","涵",
"玥","蕊","梓","宇","俊","君","泽","豪","轩","雨","欣","思","怡","彤","琪","峰","鹏","诗","德","诚","清","良","正",
"颖","灵","慧","维","壮","雄","山","柏","耀","兴","荣","华","旺","昌","胜","盛","安","顺","宁","和"};
int nameLength=(int)(Math.random()*2+2);
StringBuffer name=new StringBuffer();
name.append(firstName[firstIndex]);
while(name.length()<nameLength) {
int nextIndex=(int)(Math.random()*nextName.length);
name.append(nextName[nextIndex]);
}
return name.toString();
}
public static String createPassword() {
String password="";
for(int i=0;i<8;i++) {
int num=(int)(Math.random()*10);
password+=num;
}
return password;
}
public static int createAge() {
int age=(int)(Math.random()*30+20);
return age;
}
public static String createPhone() {
String phone="";
String[] prefix= {"138","181","139","131","130","180"};
int preNum=(int)(Math.random()*prefix.length);
phone+=prefix[preNum];
for(int i=0;i<8;i++) {
int num=(int)(Math.random()*10);
phone+=num;
}
return phone;
}
public static String createEmail() {
String email="";
for(int i=0;i<8;i++) {
int num=(int)(Math.random()*10);
email+=num;
}
String[] suffix= {"@qq.com","@126.com"};
int sufNum=(int)(Math.random()*suffix.length);
email+=suffix[sufNum];
return email;
}
特别是生成名字的功能特6,大家一定要试试。
当然,只是些小代码,希望能博大家一笑。
上一篇: 文本加密娱乐版(Java)