<commit_before>package tictactoe.GameMechanics;

import java.util.Random;

public enum Player {
    X("X"),
    O("O"),
    Neither("_");

    private String displayString;

    Player(String displayString) {
        this.displayString = displayString;
    }

    public String getDisplayString() {
        return this.displayString;
    }

    public static Player getRandomPlayer() {
        Random r = new Random(System.currentTimeMillis());
        boolean playerIsX = r.nextBoolean();
        return playerIsX ? Player.X : Player.O;
    }
}<commit_msg>add logic for swapping players<commit_after>package tictactoe.GameMechanics;

import java.util.Random;

public enum Player {
    X("X"),
    O("O"),
    Neither("_");

    private String displayString;
    /* initialize Random once as a static field to avoid super fast execution
       resulting in the same millisecond value used for several seeds. */
    private static Random rand = new Random(System.currentTimeMillis());

    Player(String displayString) {
        this.displayString = displayString;
    }

    public String getDisplayString() {
        return this.displayString;
    }

    public static Player getRandomPlayer() {
        boolean playerIsX = rand.nextBoolean();
        return playerIsX ? Player.X : Player.O;
    }

    public static Player getOtherPlayer(Player player1) {
        if(player1.equals(Player.X)) {
            return Player.O;
        } else {
            return Player.X;
        }
    }
}
{'fraction_non_alphanumeric': 0.09603760913364674, 'fraction_numerical': 0.001343183344526528, 'mean_word_length': 2.660933660933661, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556994', 'n_tokens_mistral': 414, 'n_tokens_neox': 406, 'n_words': 113}