✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Який породжуючий патерн реалізовано
public class Pages
{
public int PageCount { get; set; }
public Pages(int pageCount)
{
this.PageCount = pageCount;
}
}
public interface IBook
{
string Author { get; set; }
string Title { get; set; }
Pages Pages { get; set; }
}
public class Book : IBook, ICloneable
{
public string Title { get; set; }
public string Author { get; set; }
public Pages Pages { get; set; }
public Book(string title, string author, int pageCount)
{
Title = title;
Author = author;
Pages = new Pages(pageCount);
}
public Book DeepClone()
{
Book clone = (Book)this.MemberwiseClone();
clone.Title = String.Copy(Title);
clone.Author = String.Copy(Author);
clone.Pages = new Pages(Pages.PageCount);
return clone;
}
public object Clone()
{
return this.MemberwiseClone();
}
}