SharpLibs/MadLib/Program.cs

35 lines
934 B
C#
Raw Permalink Normal View History

2025-11-05 10:38:32 -06:00
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.");
}
}
}