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.
64 lines
1.2 KiB
64 lines
1.2 KiB
using System;
|
|
|
|
namespace Model
|
|
{
|
|
public class Skill : IEquatable<Skill>
|
|
{
|
|
public SkillType Type { get; private set; }
|
|
|
|
public string Name
|
|
{
|
|
get => name;
|
|
private init
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
{
|
|
throw new ArgumentException("a Skill needs a name");
|
|
}
|
|
name = value;
|
|
}
|
|
}
|
|
private readonly string name = null!;
|
|
|
|
public string Description
|
|
{
|
|
get => description;
|
|
set
|
|
{
|
|
if(string.IsNullOrWhiteSpace(value))
|
|
{
|
|
description = "";
|
|
return;
|
|
}
|
|
description = value;
|
|
}
|
|
}
|
|
private string description = "";
|
|
|
|
public Skill(string name, SkillType type, string description = "")
|
|
{
|
|
Name = name;
|
|
Type = type;
|
|
Description = description ?? "";
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if(ReferenceEquals(obj, null)) return false;
|
|
if(ReferenceEquals(obj, this)) return true;
|
|
if(GetType() != obj.GetType()) return false;
|
|
return Equals(obj as Skill);
|
|
}
|
|
|
|
public bool Equals(Skill? other)
|
|
=> Name.Equals(other?.Name) && Type == other.Type;
|
|
|
|
public override int GetHashCode()
|
|
=> Name.GetHashCode() % 281;
|
|
|
|
public override string ToString()
|
|
=> $"{Name} ({Type})";
|
|
}
|
|
}
|
|
|