Instructions

Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He says 'Fine. Be that way!' if you address him without actually saying anything.
He answers 'Whatever.' to anything else.

C# Test

  1. // This file was auto-generated based on version 1.0.0 of the canonical data.
  2.  
  3. using Xunit;
  4.  
  5. public class BobTest
  6. {
  7. [Fact]
  8. public void Stating_something()
  9. {
  10. Assert.Equal("Whatever.", Bob.Response("Tom-ay-to, tom-aaaah-to."));
  11. }
  12.  
  13. [Fact(Skip = "Remove to run test")]
  14. public void Shouting()
  15. {
  16. Assert.Equal("Whoa, chill out!", Bob.Response("WATCH OUT!"));
  17. }
  18.  
  19. [Fact(Skip = "Remove to run test")]
  20. public void Shouting_gibberish()
  21. {
  22. Assert.Equal("Whoa, chill out!", Bob.Response("FCECDFCAAB"));
  23. }
  24.  
  25. [Fact(Skip = "Remove to run test")]
  26. public void Asking_a_question()
  27. {
  28. Assert.Equal("Sure.", Bob.Response("Does this cryogenic chamber make me look fat?"));
  29. }
  30.  
  31. [Fact(Skip = "Remove to run test")]
  32. public void Asking_a_numeric_question()
  33. {
  34. Assert.Equal("Sure.", Bob.Response("You are, what, like 15?"));
  35. }
  36.  
  37. [Fact(Skip = "Remove to run test")]
  38. public void Asking_gibberish()
  39. {
  40. Assert.Equal("Sure.", Bob.Response("fffbbcbeab?"));
  41. }
  42.  
  43. [Fact(Skip = "Remove to run test")]
  44. public void Talking_forcefully()
  45. {
  46. Assert.Equal("Whatever.", Bob.Response("Let's go make out behind the gym!"));
  47. }
  48.  
  49. [Fact(Skip = "Remove to run test")]
  50. public void Using_acronyms_in_regular_speech()
  51. {
  52. Assert.Equal("Whatever.", Bob.Response("It's OK if you don't want to go to the DMV."));
  53. }
  54.  
  55. [Fact(Skip = "Remove to run test")]
  56. public void Forceful_question()
  57. {
  58. Assert.Equal("Whoa, chill out!", Bob.Response("WHAT THE HELL WERE YOU THINKING?"));
  59. }
  60.  
  61. [Fact(Skip = "Remove to run test")]
  62. public void Shouting_numbers()
  63. {
  64. Assert.Equal("Whoa, chill out!", Bob.Response("1, 2, 3 GO!"));
  65. }
  66.  
  67. [Fact(Skip = "Remove to run test")]
  68. public void Only_numbers()
  69. {
  70. Assert.Equal("Whatever.", Bob.Response("1, 2, 3"));
  71. }
  72.  
  73. [Fact(Skip = "Remove to run test")]
  74. public void Question_with_only_numbers()
  75. {
  76. Assert.Equal("Sure.", Bob.Response("4?"));
  77. }
  78.  
  79. [Fact(Skip = "Remove to run test")]
  80. public void Shouting_with_special_characters()
  81. {
  82. Assert.Equal("Whoa, chill out!", Bob.Response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"));
  83. }
  84.  
  85. [Fact(Skip = "Remove to run test")]
  86. public void Shouting_with_no_exclamation_mark()
  87. {
  88. Assert.Equal("Whoa, chill out!", Bob.Response("I HATE YOU"));
  89. }
  90.  
  91. [Fact(Skip = "Remove to run test")]
  92. public void Statement_containing_question_mark()
  93. {
  94. Assert.Equal("Whatever.", Bob.Response("Ending with ? means a question."));
  95. }
  96.  
  97. [Fact(Skip = "Remove to run test")]
  98. public void Non_letters_with_question()
  99. {
  100. Assert.Equal("Sure.", Bob.Response(":) ?"));
  101. }
  102.  
  103. [Fact(Skip = "Remove to run test")]
  104. public void Prattling_on()
  105. {
  106. Assert.Equal("Sure.", Bob.Response("Wait! Hang on. Are you going to be OK?"));
  107. }
  108.  
  109. [Fact(Skip = "Remove to run test")]
  110. public void Silence()
  111. {
  112. Assert.Equal("Fine. Be that way!", Bob.Response(""));
  113. }
  114.  
  115. [Fact(Skip = "Remove to run test")]
  116. public void Prolonged_silence()
  117. {
  118. Assert.Equal("Fine. Be that way!", Bob.Response(" "));
  119. }
  120.  
  121. [Fact(Skip = "Remove to run test")]
  122. public void Alternate_silence()
  123. {
  124. Assert.Equal("Fine. Be that way!", Bob.Response("\t\t\t\t\t\t\t\t\t\t"));
  125. }
  126.  
  127. [Fact(Skip = "Remove to run test")]
  128. public void Multiple_line_question()
  129. {
  130. Assert.Equal("Whatever.", Bob.Response("\nDoes this cryogenic chamber make me look fat?\nno"));
  131. }
  132.  
  133. [Fact(Skip = "Remove to run test")]
  134. public void Starting_with_whitespace()
  135. {
  136. Assert.Equal("Whatever.", Bob.Response(" hmmmmmmm..."));
  137. }
  138.  
  139. [Fact(Skip = "Remove to run test")]
  140. public void Ending_with_whitespace()
  141. {
  142. Assert.Equal("Sure.", Bob.Response("Okay if like my spacebar quite a bit? "));
  143. }
  144.  
  145. [Fact(Skip = "Remove to run test")]
  146. public void Other_whitespace()
  147. {
  148. Assert.Equal("Fine. Be that way!", Bob.Response("\n\r \t"));
  149. }
  150.  
  151. [Fact(Skip = "Remove to run test")]
  152. public void Non_question_ending_with_whitespace()
  153. {
  154. Assert.Equal("Whatever.", Bob.Response("This is a statement ending with whitespace "));
  155. }
  156. }

C# Solution

  1. using System;
  2.  
  3. /*
  4. question: last character is '?'
  5. answer: "Sure."
  6.  
  7. yell: all characters are uppercase
  8. answer: "Whoa, chill out!"
  9.  
  10. silence: empty
  11. answer: "Fine. Be that way!"
  12.  
  13. default
  14. answer: "Whatever"
  15.  
  16. */
  17. public static class Bob
  18. {
  19. public static string Response(string statement)
  20. {
  21. if (statement.Trim().EndsWith('?'))
  22. {
  23. return "Sure.";
  24. }
  25. if (statement.ToUpper() == statement)
  26. {
  27. return "Whoa, chill out!";
  28. }
  29. if (statement.Trim() == "")
  30. {
  31. return "Fine. Be that way!";
  32. }
  33. return "Whatever.";
  34.  
  35. }
  36. }

Basic 001 Bob的更多相关文章

  1. 从零开始PHP攻略(001)——Bob的汽车零部件商店

    1.创建订单表单 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...

  2. PHP7 扩展之自动化测试

    在安装 PHP7 及各种扩展的过程中,如果你是用源码安装,会注意到在 make 成功之后总会有一句提示:Don't forget to run 'make test'. 这个 make test 就是 ...

  3. Hexo 下 Markdown 的配置与学习

    本篇 更换 Hexo 下的 Markdown 渲染插件 学习 Markdown 基本语法 ✎更换 Markdown 渲染插件 ✎原因 Hexo 内置的默认渲染插件是 hexo-renderer-mar ...

  4. TypeScript学习指南第一章--基础数据类型(Basic Types)

    基础数据类型(Basic Types) 为了搭建应用程序,我们需要使用一些基础数据类型比如:numbers,strings,structures,boolean等等. 在TypeScript中除了Ja ...

  5. Linux--Introduction and Basic commands(Part one)

    Welcome to Linux world! Introduction and Basic commands--Part one J.C 2018.3.11 Chapter 1 What Is Li ...

  6. Spring Security(二十):6.2.3 Form and Basic Login Options

    You might be wondering where the login form came from when you were prompted to log in, since we mad ...

  7. 《Visual Basic开发实战1200例》包括第I卷、第II卷共计1200个例子,本书是第I卷,共计600个例子。

    本书以开发人员在项目开发中经常遇到的问题和必须掌握的技术为中心,介绍了应用Visual Basic进行程序开发各个方面的知识和技巧.主要包括基础知识.窗体界面设计.控件应用等.全书分6篇20章,共计6 ...

  8. PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642 题目描述: 拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下: 每 ...

  9. Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结

    Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...

随机推荐

  1. wordpress如何利用插件添加优酷土豆等视频到自己的博客上

    wordpress有时候需要添加优酷.土豆等网站的视频到自己的博客上,传统的分享方法不能符合电脑端和手机端屏幕大小的需求,又比较繁琐,怎样利用插件的方法进行添加呢,本视频向你介绍一款这样的插件——Sm ...

  2. 元数据Metadata

    元数据是什么? 元数据(Metadata),又称中介数据.中继数据,为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置.历史数据. ...

  3. ckeditor django admin 中使用

    ckeditor settings配置 ############ # CKEDITOR # ############ MEDIA_ROOT = os.path.join(BASE_DIR, 'medi ...

  4. CSAPP:第十一章 网络编程

    CSAPP:第十一章 网络编程 11.1 客户端服务器模型11.2 全球IP因特网11.3 套接字接口 11.1 客户端服务器模型   每个网络应用都是基于客户端-服务器模型.采用这个模型,一个应用是 ...

  5. Net core 关于缓存的实现

    在很多项目中, 需要用到缓存,借鉴网上前辈们的一些经验,自己再进行总结简化了一些, 做出如下的缓存操作,其中包含内存缓存(IMemoryCache) 和 Redis 缓存; 一.前提内容, 导入两个包 ...

  6. java基础-04泛型

    介绍 泛型就是数据类型的参数化表示,泛型的本质是参数化类型,常用E代表任何数据类型,在实际使用的时候把实际的数据类型传递给E. 泛型的好处是设计通用的功能,多个数据类型可以共用. 泛型类型E只能代表O ...

  7. iptables之语法

    一iptables概念 防火墙分类 分为硬件防火墙和软件防火墙 硬件防火墙一般放在外网的最前面,公司的拓扑的最外面 iptables虽然称为防火墙,但是不能当做整个公司的出口防火墙,和动戈几千万,几百 ...

  8. 第二部分之Redis服务器(第十四章)

    Redis服务器复制和多个客户端建立网络连接,处理客户端发送的命令请求,在数据库中保存客户端执行命令所产生的数据. 一,命令请求的执行过程 客户端向服务器发送命令请求 set key value 服务 ...

  9. AngularJS路由变化 监听方法

    #使用AngularJS时,当路由发生改变时,我们需要做某些处理,此时可以监听路由事件,常用的是$routeStartChange, $routeChangeSuccess ##使用场景:在路由配置文 ...

  10. [ffmpeg] 解码API

    版本迭代 ffmpeg解码API经过了好几个版本的迭代,上一个版本的API是 解码视频:avcodec_decode_video2 解码音频:avcodec_decode_audio4 我们现在能看到 ...