You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
using System;
|
|
using System.Xml.Linq;
|
|
|
|
namespace Model
|
|
{
|
|
public class Player : IEquatable<Player>
|
|
{
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return name;
|
|
}
|
|
internal set
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(value) && !value.Equals(""))
|
|
{
|
|
name = value;
|
|
}
|
|
else throw new ArgumentException("player name may never be empty or null");
|
|
}
|
|
}
|
|
|
|
private string name;
|
|
|
|
public Player(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public Player(Player player)
|
|
{
|
|
if (player != null)
|
|
{
|
|
Name = player.name;
|
|
}
|
|
else throw new ArgumentException("you may not make a copy of a null player");
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Name;
|
|
}
|
|
|
|
public bool Equals(Player other)
|
|
{
|
|
return Name.ToUpper() == other.Name.ToUpper();
|
|
}
|
|
|
|
public override bool Equals(Object obj)
|
|
{
|
|
if (obj is not Player)
|
|
{
|
|
return false;
|
|
}
|
|
return Equals(obj as Player);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Name.ToUpper().GetHashCode();
|
|
}
|
|
}
|
|
}
|