|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
|
|
|
|
namespace Model
|
|
|
|
|
{
|
|
|
|
@ -10,6 +11,8 @@ namespace Model
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class BaseItem : IDisplayable, IEquatable<BaseItem>
|
|
|
|
|
{
|
|
|
|
|
#region Private Attributes
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The identifier of an Item.<br/>
|
|
|
|
|
/// The first number correspond to the typs of the Item.
|
|
|
|
@ -20,19 +23,28 @@ namespace Model
|
|
|
|
|
init => _id = value;
|
|
|
|
|
}
|
|
|
|
|
protected uint _id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Public Properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A short description of the Item. Useful to know what this Item stand for.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
protected BaseItem(uint id, string description="Any Item.")
|
|
|
|
|
{
|
|
|
|
|
Id = id; Description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
@ -43,7 +55,8 @@ namespace Model
|
|
|
|
|
$"______\n\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IDisplayable Implementation
|
|
|
|
|
#region IDisplayable Implementation
|
|
|
|
|
|
|
|
|
|
public void DisplayId()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($".Id - {Id}");
|
|
|
|
@ -59,27 +72,23 @@ namespace Model
|
|
|
|
|
Console.WriteLine(this.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IEquatable<BaseItem> implementation
|
|
|
|
|
public bool Equals(BaseItem? other)
|
|
|
|
|
{
|
|
|
|
|
if (other != null)
|
|
|
|
|
return this.Id.Equals(other.Id);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#region IEquatable<BaseItem> implementation
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
|
public int GetHashCode([DisallowNull] BaseItem obj)
|
|
|
|
|
{
|
|
|
|
|
BaseItem? baseItem = obj as BaseItem;
|
|
|
|
|
if (baseItem == null) return false;
|
|
|
|
|
if (baseItem == this) return true;
|
|
|
|
|
|
|
|
|
|
return this.Id.Equals(baseItem.Id);
|
|
|
|
|
return obj.Id.GetHashCode() + obj.Description.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
public bool Equals(BaseItem? other)
|
|
|
|
|
{
|
|
|
|
|
return this.Id.GetHashCode();
|
|
|
|
|
if (other == null) return false;
|
|
|
|
|
return (this.Id == other.Id) && (this.Description == other.Description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|