Better keyboard, cosmetics

This commit is contained in:
Piotr Czajkowski
2022-01-01 12:15:13 +01:00
parent 62645703d1
commit e9cc632c7b

View File

@@ -13,15 +13,17 @@ namespace Buzzword
Console.WriteLine(); Console.WriteLine();
} }
static string keys = "type a 'Y' for another phrase or 'N' to quit";
static void Instructions() static void Instructions()
{ {
Console.WriteLine("This program prints highly acceptable phrases in\n" Console.WriteLine("This program prints highly acceptable phrases in\n"
+ "'Educator-speak'that you can work into reports\n" + "'Educator-speak'that you can work into reports\n"
+ "and speeches. Whenever a question mark is printed,\n" + "and speeches. Whenever a question mark is printed,\n"
+ "type a 'Y' for another phrase or 'N' to quit."); + $"{keys}.");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Here's the first phrase:"); Console.Write("Here's the first phrase:");
} }
static string[] Phrases = new[] static string[] Phrases = new[]
@@ -50,7 +52,21 @@ namespace Buzzword
{ {
return $"{Capitalize(Phrases[(int)(13 * rnd.NextDouble() + 1) % Phrases.Length])} " return $"{Capitalize(Phrases[(int)(13 * rnd.NextDouble() + 1) % Phrases.Length])} "
+ $"{Phrases[(int)(13 * rnd.NextDouble() + 14) % Phrases.Length]} " + $"{Phrases[(int)(13 * rnd.NextDouble() + 14) % Phrases.Length]} "
+ $"{Phrases[(int)(13 * rnd.NextDouble() + 27) % Phrases.Length]}."; + $"{Phrases[(int)(13 * rnd.NextDouble() + 27) % Phrases.Length]}";
}
static bool Decision()
{
while (true)
{
var answer = Console.ReadKey();
if (answer.Key == ConsoleKey.Y)
return true;
else if (answer.Key == ConsoleKey.N)
return false;
else
Console.WriteLine($"\n{keys}");
}
} }
static void Main(string[] args) static void Main(string[] args)
@@ -62,11 +78,13 @@ namespace Buzzword
{ {
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(GeneratePhrase()); Console.WriteLine(GeneratePhrase());
Console.WriteLine();
var answer = Console.ReadKey(); if (!Decision())
if (answer.Key == ConsoleKey.N)
break; break;
} }
Console.WriteLine("\nCome back when you need help with another report!");
} }
} }
} }