using System.Collections.Generic;
public static void Main()
Console.WriteLine("Welcome to Book creator!");
Console.WriteLine("Would you like to make a Novel or History book?");
string bookType = Console.ReadLine();
BookFactory bookFactory = new CoolBookFactory(bookType);
Book userBook = bookFactory.Create();
Console.WriteLine("PAGES -----");
foreach (var page in userBook.pages)
Console.WriteLine(page.GetType().Name);
abstract class BookFactory
public abstract Book Create();
class CoolBookFactory : BookFactory
public string BookType { get; private set; }
public CoolBookFactory(string bookType)
this.BookType = bookType;
public override Book Create()
if (this.BookType == "Novel")
if (this.BookType == "History")
return new HistoryBook();
public List<Page> pages = new List<Page>();
this.pages.Add(new TitlePage());
this.pages.Add(new EventPage());
this.pages.Add(new AboutTheAuthorPage());
this.pages.Add(new AcknowledgmentsPage());
this.pages.Add(new UnitsPage());
this.pages.Add(new GlossaryPage());
class TitlePage : Page {}
class EventPage : Page {}
class AboutTheAuthorPage : Page {}
class AcknowledgmentsPage: Page {}
class UnitsPage : Page {}
class GlossaryPage : Page {}