exercism/csharp/bob/Bob.cs
2017-08-13 09:44:29 -04:00

26 lines
No EOL
646 B
C#

using System;
using System.Linq;
public static class Bob
{
public static string Response(string statement)
{
string trimmedStatement = statement.Trim();
if (trimmedStatement.Length == 0)
{
return "Fine. Be that way!";
}
if (trimmedStatement.Where((char x) => x != ' ' || x != '!' || x != '?').All((char x) => Enumerable.Range('A', 'Z' + 1).Contains(x)) || trimmedStatement.Last() == '!')
{
return "Whoa, chill out!";
}
if (trimmedStatement.Last() == '?')
{
return "Sure.";
}
return "Whatever.";
}
}