Как правильно добавить счётчик?
Хочу добавить счётчик книг к этому проекту (он не мой) : https://github.com/shwanoff/BookShop/tree/master Пришёл к тому, что не могу грамотно реализовать идею. Получилось так:
public interface IBook
{
string Author { get; set; }
string Name { get; set; }
int Price { get; set; }
}
public interface ICounter
{
int Count { get; set; }
void Reduce(int count = 1);
void Add(int count = 1);
}
public class Book : IBook, ICounter
{
public string Author { get; set; }
public string Name { get; set; }
public int Price { get; set; }
public int Count { get; set; }
public void Add(int count = 1)
{
realisation;
}
public void Reduce(int count = 1)
{
realisation;
}
}
Хочу понять как это сделать, и почему.
Источник: Stack Overflow на русском