Skip to content

Instantly share code, notes, and snippets.

@200even
Created July 13, 2015 21:50
Show Gist options
  • Save 200even/41fa0ed2b47a3639e33a to your computer and use it in GitHub Desktop.
Save 200even/41fa0ed2b47a3639e33a to your computer and use it in GitHub Desktop.
Scott - Week3.Day1 Bob
public class Bob
{
public string Hey(string remark)
{
if (remarkIsSilence(remark))
{
return "Fine. Be that way!";
}
else if (asking_a_question(remark))
{
return "Sure.";
}
else if (remarkIsShouting(remark))
{
return "Whoa, chill out!";
}
return "Whatever.";
}
private bool asking_a_question(string remark)
{
if (!remark.All(x => char.IsUpper(x) || char.IsPunctuation(x) || char.IsSeparator(x) || char.IsSymbol(x)))
{
return remark.EndsWith("?");
}
else return false;
}
private bool remarkIsShouting(string remark)
{
if (!remark.All(x => char.IsNumber(x) || char.IsPunctuation(x)||char.IsSeparator(x)))
{
return remark.All(x => char.IsUpper(x) || char.IsPunctuation(x) || char.IsSeparator(x) || char.IsSymbol(x) || char.IsNumber(x));
}
else return false;
}
private bool remarkIsSilence(string remark)
{
return remark.All(x => char.IsSeparator(x) || char.IsWhiteSpace(x));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment