com.github.vatbub.tictactoe.NameList.java Source code

Java tutorial

Introduction

Here is the source code for com.github.vatbub.tictactoe.NameList.java

Source

package com.github.vatbub.tictactoe;

/*-
 * #%L
 * tictactoe
 * %%
 * Copyright (C) 2016 - 2017 Frederik Kammel
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import com.github.vatbub.randomusers.Generator;
import com.github.vatbub.randomusers.result.Nationality;
import com.github.vatbub.randomusers.result.RandomUser;
import org.apache.commons.lang.WordUtils;

import java.util.Collections;

/**
 * A list of firstNames for ai players
 */
@SuppressWarnings("WeakerAccess")
public class NameList {
    public static String getNextName() {
        RandomUser.RandomUserSpec randomUserSpec = new RandomUser.RandomUserSpec();
        randomUserSpec.setNationalities(Collections.singletonList(Nationality.getFromCurrentDefaultLocale()));
        RandomUser randomUser = Generator.generateRandomUser(randomUserSpec);
        return WordUtils.capitalize(randomUser.getName().getFirstName() + " " + randomUser.getName().getLastName());
    }
}