citylist.java

来自「TestDataBuilder是一个采用Java编写的」· Java 代码 · 共 48 行

JAVA
48
字号
package resources.datatype.address;

import java.util.ArrayList;
import java.util.List;

import com.testDataBuilder.util.RandomUtil;

public class CityList {

    private String state;

    private int length = 0;
    
    private List<String> citys = new ArrayList<String>();
    
    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public List<String> getCitys() {
        return citys;
    }

    public void setCitys(List<String> citys) {
        this.citys = citys;
    }
    
    public String randomCity(){
        if(length == 0){
            length = citys.size();
        }
        int index = RandomUtil.randomInt(0, length-1);
        return this.citys.get(index);
    }
    
    public String randomStateCity(){
        if(length == 0){
            length = citys.size();
        }
        int index = RandomUtil.randomInt(0, length-1);
        return this.getState() + "," + this.citys.get(index);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?