Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System.Linq;
  2.  
  3. namespace Week3Day1Homework
  4. {
  5. internal class Bob
  6. {
  7. public string hey(string input)
  8. {
  9. if (isYelling(input))
  10. {
  11. return "Whoa, chill out!";
  12. }
  13. if (isAQuestion(input))
  14. {
  15. return "Sure.";
  16. }
  17. if (sayingNothing(input))
  18. {
  19. return "Fine. Be that way!";
  20. }
  21. else
  22. {
  23. return "Whatever.";
  24. }
  25. }
  26. private bool isYelling(string remark)
  27. {
  28. if (remark.All(x => char.IsUpper(x) || char.IsPunctuation(x) || char.IsSeparator(x) || char.IsNumber(x) || char.IsSymbol(x)) && remark.Any(x => char.IsUpper(x)))
  29. {
  30. return true;
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36.  
  37. }
  38. private bool isAQuestion(string remark)
  39. {
  40. if (remark.EndsWith("?"))
  41. {
  42. return true;
  43. }
  44. else
  45. {
  46. return false;
  47. }
  48. }
  49. private bool sayingNothing(string remark)
  50. {
  51. if ((remark == "") || (!remark.Any(x => char.IsLetter(x) || char.IsNumber(x))))
  52. {
  53. return true;
  54. }
  55. else
  56. {
  57. return false;
  58. }
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement