forked from ChayoteJarocho/tlapohualli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
45 lines (41 loc) · 1.48 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace Tlapohualli
{
/// <summary>
/// This program converts integer number names (base 10) to their Nahuatl translation (base 20).
/// </summary>
class Program
{
private static readonly string Quit = "quit";
private static readonly string Instructions = $"Must be a number between {Translator.MinNumber} and {Translator.MaxNumber}.";
public static void Main()
{
Log.Info("-----------------");
Log.Info("-- TLAPOHUALLI --");
Log.Info("-----------------");
Log.Info("Type an number to get its Nahuatl name.");
Log.Info($"Type '{Quit}' to exit program.");
Log.Info(Instructions);
string selection = string.Empty;
while (selection.ToLowerInvariant() != Quit)
{
Console.Write("Number: ");
selection = Console.ReadLine();
if (!int.TryParse(selection, out int number))
{
Log.Error($"{Instructions}");
}
else if (number >= Translator.MinNumber && number <= Translator.MaxNumber)
{
string translation = Translator.Translate(number);
Log.Success($"Nahuatl: {translation}");
}
else
{
Log.Error($"{Instructions}");
}
}
Log.Info("Goodbye!");
}
}
}