Skip to content
Snippets Groups Projects
Player.java 1.08 KiB
Newer Older
Jan Kožusznik's avatar
Jan Kožusznik committed
package cz.jezek.lab11;

Jan Kožusznik's avatar
Jan Kožusznik committed
import java.util.Objects;

Jan Kožusznik's avatar
Jan Kožusznik committed
public class Player {

	private String firstName;
	private String lastName;

	public static Player generateRandom() {
		return new Player(RandomGenarator.selectRandom(RandomGenarator.NAMES),
				RandomGenarator.selectRandom(RandomGenarator.SURNAMES));
	}

	public Player(String firstName, String lastName) {
		super();
		this.firstName = firstName;
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Override
	public int hashCode() {
Jan Kožusznik's avatar
Jan Kožusznik committed
		return Objects.hash(firstName, lastName);
Jan Kožusznik's avatar
Jan Kožusznik committed
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
Jan Kožusznik's avatar
Jan Kožusznik committed
		if (obj instanceof Player other) {
			return Objects.equals(firstName, other.firstName) && Objects.equals(lastName, other.lastName);
		}
		return false;
		
Jan Kožusznik's avatar
Jan Kožusznik committed
	}

	@Override
	public String toString() {
		return firstName + " " + lastName;
	}

}