mirror of
https://github.com/tonytins/PublishTimes.git
synced 2025-03-14 20:01:20 +00:00
Minor quality of life changes
This commit is contained in:
parent
df33078d1a
commit
fa5a5b1b2e
1 changed files with 13 additions and 10 deletions
23
Program.cs
23
Program.cs
|
@ -84,32 +84,35 @@ string SelectTopics(List<string> topics)
|
|||
foreach (var topic in topics)
|
||||
{
|
||||
numOfTopics++;
|
||||
topicDict.Add(numOfTopics, topic.Trim());
|
||||
userChoices.Add($"{numOfTopics} {topic.Trim()}");
|
||||
var title = topic.Trim();
|
||||
topicDict.Add(numOfTopics, title);
|
||||
userChoices.Add($"{numOfTopics} {title}");
|
||||
}
|
||||
|
||||
var selection = string.Join(", ", userChoices.ToArray());
|
||||
Console.WriteLine($"Select a Topic (Choose a Number){Environment.NewLine}{selection}");
|
||||
Console.WriteLine($"{Environment.NewLine}Select a Topic (Choose a Number){Environment.NewLine}{selection}");
|
||||
var input = Console.ReadLine();
|
||||
|
||||
//
|
||||
// Attempt to parse a number.
|
||||
if (int.TryParse(input, out topicNum) == true)
|
||||
topicChoice = topicDict[topicNum];
|
||||
else
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Write($"{Environment.NewLine}Try again.");
|
||||
NewTopic(topics);
|
||||
}
|
||||
NewTopic(topics, false);
|
||||
|
||||
return topicChoice;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects a new topic either by prompting the user or randomly choosing one from the list.
|
||||
/// </summary>
|
||||
/// <param name="topics">A list of available topics.</param>
|
||||
/// <param name="retry">Indicates whether to prompt the user again if no selection was made.</param>
|
||||
/// <returns>The selected topic as a string.</returns>
|
||||
string NewTopic(List<string> topics, bool retry = false)
|
||||
{
|
||||
var newTopic = "";
|
||||
|
||||
if (UserChoice("Choose a Topic?"))
|
||||
if (UserChoice("Choose a Topic?") || retry)
|
||||
newTopic = SelectTopics(topics);
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue