Created
July 13, 2015 21:50
-
-
Save 200even/41fa0ed2b47a3639e33a to your computer and use it in GitHub Desktop.
Scott - Week3.Day1 Bob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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