Skip to content

Commit

Permalink
增加随机大学专业名称
Browse files Browse the repository at this point in the history
  • Loading branch information
yindz committed Apr 23, 2022
1 parent 2b3b28f commit 0af1895
Show file tree
Hide file tree
Showing 2 changed files with 487 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/apifan/common/random/source/EducationSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public class EducationSource {
private List<String> collegeList;
private static final List<String> numberList = Lists.newArrayList("一", "二", "三", "四", "五", "六", "七", "八", "九", "十");

private List<String> majorList;

private EducationSource() {
collegeList = ResourceUtils.readLines("college.txt");
majorList = ResourceUtils.base64DecodeLines(ResourceUtils.readLines("college-major.txt"));
}

/**
Expand Down Expand Up @@ -110,6 +113,15 @@ public String randomClassName() {
return RandomUtils.nextInt(1, 11) + "班";
}

/**
* 获取随机大学专业名称
*
* @return 大学专业名称
*/
public String randomMajorName() {
return ResourceUtils.getRandomElement(majorList);
}

private String getGradeName(int grade) {
Preconditions.checkArgument(grade > 0 && grade < numberList.size(), "grade数字错误");
return numberList.get(grade - 1);
Expand Down
Loading

0 comments on commit 0af1895

Please sign in to comment.