// Display console information for generating a new book. public void RenderGenerateBook(InsightFacade insightFacade) { Console.WriteLine("\nGenerate book after two or more books are trained together."); var trainedCollections = RenderListBookCollectionids(insightFacade); if (trainedCollections == null) { Console.WriteLine("\nNo bookCollections added."); return; } Console.WriteLine("\nThe following bookCollections are trained:" + trainedCollections); Console.WriteLine("\nWrite the id of the collection you wish to generate a book for. Format: id"); var id = Console.ReadLine().Trim(); var addedColIds = insightFacade.ListBookCollectionNames(); if (!IdUtil.IdAlreadyAdded(id, addedColIds) || !IdUtil.IsValid(id)) { Console.WriteLine($"Aborting, id: {id} is invalid."); return; } try { var outputLocation = insightFacade.GenerateBook(id, _maxDepth, _numTrees, _numAdjacentExamples); Console.WriteLine($"New book generated at {outputLocation}."); } catch (Exception e) { Console.WriteLine($"New book not generated. " + e.Message); return; } }