Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- namespace Week3Day1Homework
- {
- internal class Bob
- {
- public string hey(string input)
- {
- if (isYelling(input))
- {
- return "Whoa, chill out!";
- }
- if (isAQuestion(input))
- {
- return "Sure.";
- }
- if (sayingNothing(input))
- {
- return "Fine. Be that way!";
- }
- else
- {
- return "Whatever.";
- }
- }
- private bool isYelling(string remark)
- {
- 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)))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool isAQuestion(string remark)
- {
- if (remark.EndsWith("?"))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool sayingNothing(string remark)
- {
- if ((remark == "") || (!remark.Any(x => char.IsLetter(x) || char.IsNumber(x))))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement