I need to make this magazine_list that holds only unique values and do it by using dictionary and multiton pattern.
List cannot have two objects with the same both name and price.
I found only one example of multiton pattern in c# and it didn't solve my problem.
It's simplified version of code that I already have, but these are the most important things of that problem.
public class Product
{
string name;
int price;
}
public class Coffee : Product
{
public Coffee(string _name, int _price)
{
name = _name;
price = _price;
}
}
public class Tea : Product
{
public Tea(string _name, int _price)
{
name = _name;
price = _price;
}
}
public class Magazine
{
List<Product> magazine_list;
public Magazine()
{
List<Product> magazine_list = new List<Product>();
}
public void add(Product p)
{
magazine_list.Add(p);
}
}