35 lines
934 B
C#
35 lines
934 B
C#
|
|
namespace MadLib;
|
|||
|
|
|
|||
|
|
public class Program
|
|||
|
|
{
|
|||
|
|
public static void Main(string[] args)
|
|||
|
|
{
|
|||
|
|
var category = GetChoice();
|
|||
|
|
var storyGenerator = new StoryGenerator(category);
|
|||
|
|
|
|||
|
|
storyGenerator.Generate();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static StoryGenerator.Categories GetChoice()
|
|||
|
|
{
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
Console.WriteLine("Choose a category:");
|
|||
|
|
StoryGenerator.DisplayCategories();
|
|||
|
|
|
|||
|
|
var choice = Console.ReadLine();
|
|||
|
|
if (string.IsNullOrWhiteSpace(choice))
|
|||
|
|
{
|
|||
|
|
Console.WriteLine("Invalid input.");
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var selectedCategory = int.Parse(choice.Trim()) - 1;
|
|||
|
|
|
|||
|
|
if (Enum.IsDefined(typeof(StoryGenerator.Categories), selectedCategory))
|
|||
|
|
return (StoryGenerator.Categories)selectedCategory;
|
|||
|
|
|
|||
|
|
Console.WriteLine("Please enter a valid category.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|