using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
///
/// Holds informations about a single product
///
public class Product: IEquatable, IComparable
{
///
/// Identification number of product
///
public string ID { get; set; }
///
/// Name of product
///
public string Name { get; set; }
///
/// Price of product
///
public decimal Price { get; set; }
public Product(string iD, string name, decimal price)
{
ID = iD;
Name = name;
Price = price;
}
public override string ToString()
{
return String.Format("Product{ID = '{0}'}", ID);
}
public bool Equals(Product other)
{
return ID == other.ID &&
Name == other.Name &&
Price == other.Price;
}
public override int GetHashCode()
{
int hashCode = 560300832;
hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(ID);
hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Name);
hashCode = hashCode * -1521134295 + Price.GetHashCode();
return hashCode;
}
public int CompareTo(Product other)
{
return ID.CompareTo(other.ID);
}
}
}