July 2019
Intermediate to advanced
410 pages
10h 32m
English
The InventoryCommandFactory class is an implementation of the Factory pattern using .Net classes, which requires both readings of, and writing to, the collection of books:
public class InventoryCommandFactory : IInventoryCommandFactory{ private readonly IUserInterface _userInterface; private readonly IInventoryContext _context; public InventoryCommandFactory(IUserInterface userInterface, IInventoryContext context) { _userInterface = userInterface; _context = context; } public InventoryCommand GetCommand(string input) { switch (input.ToLower()) { case "q": case "quit": return new QuitCommand(_userInterface); case "a": case "addinventory": return new AddInventoryCommand(_userInterface, _context); case "g": case "getinventory": ...Read now
Unlock full access