Initial commit
This commit is contained in:
51
Invitation.cs
Normal file
51
Invitation.cs
Normal file
@ -0,0 +1,51 @@
|
||||
namespace Activities
|
||||
{
|
||||
public class Invitation
|
||||
{
|
||||
public static string GetValue(string prompt)
|
||||
{
|
||||
Console.Write(prompt);
|
||||
string? value = Console.ReadLine();
|
||||
if (value == null)
|
||||
{
|
||||
Console.WriteLine("No input provided.");
|
||||
value = GetValue(prompt);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DateOnly GetDate(string prompt)
|
||||
{
|
||||
string value = GetValue(prompt);
|
||||
DateOnly date;
|
||||
try
|
||||
{
|
||||
date = DateOnly.Parse(value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Invalid date provided.");
|
||||
date = GetDate(prompt);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
public static bool GetResponse(string prompt)
|
||||
{
|
||||
string value = GetValue(prompt);
|
||||
if (value.Equals("y", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (value.Equals("n", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid response provided.");
|
||||
return GetResponse(prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user