mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
Starting sentence from capital letter
This commit is contained in:
@@ -36,11 +36,19 @@ namespace Buzzword
|
|||||||
"performance", "reinforcement", "open classroom", "resource",
|
"performance", "reinforcement", "open classroom", "resource",
|
||||||
"structure", "facility", "environment" };
|
"structure", "facility", "environment" };
|
||||||
|
|
||||||
|
static string Capitalize(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return input.Substring(0, 1).ToUpper() + input[1..];
|
||||||
|
}
|
||||||
|
|
||||||
static Random rnd = new Random(1);
|
static Random rnd = new Random(1);
|
||||||
|
|
||||||
static string GeneratePhrase()
|
static string GeneratePhrase()
|
||||||
{
|
{
|
||||||
return $"{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]}.";
|
||||||
}
|
}
|
||||||
@@ -54,8 +62,8 @@ namespace Buzzword
|
|||||||
{
|
{
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine(GeneratePhrase());
|
Console.WriteLine(GeneratePhrase());
|
||||||
var answer = Console.ReadKey();
|
|
||||||
|
|
||||||
|
var answer = Console.ReadKey();
|
||||||
if (answer.Key == ConsoleKey.N)
|
if (answer.Key == ConsoleKey.N)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user