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

 // This file was auto-generated based on version 1.0.0 of the canonical data.

 using Xunit;

 public class BobTest
{
[Fact]
public void Stating_something()
{
Assert.Equal("Whatever.", Bob.Response("Tom-ay-to, tom-aaaah-to."));
} [Fact(Skip = "Remove to run test")]
public void Shouting()
{
Assert.Equal("Whoa, chill out!", Bob.Response("WATCH OUT!"));
} [Fact(Skip = "Remove to run test")]
public void Shouting_gibberish()
{
Assert.Equal("Whoa, chill out!", Bob.Response("FCECDFCAAB"));
} [Fact(Skip = "Remove to run test")]
public void Asking_a_question()
{
Assert.Equal("Sure.", Bob.Response("Does this cryogenic chamber make me look fat?"));
} [Fact(Skip = "Remove to run test")]
public void Asking_a_numeric_question()
{
Assert.Equal("Sure.", Bob.Response("You are, what, like 15?"));
} [Fact(Skip = "Remove to run test")]
public void Asking_gibberish()
{
Assert.Equal("Sure.", Bob.Response("fffbbcbeab?"));
} [Fact(Skip = "Remove to run test")]
public void Talking_forcefully()
{
Assert.Equal("Whatever.", Bob.Response("Let's go make out behind the gym!"));
} [Fact(Skip = "Remove to run test")]
public void Using_acronyms_in_regular_speech()
{
Assert.Equal("Whatever.", Bob.Response("It's OK if you don't want to go to the DMV."));
} [Fact(Skip = "Remove to run test")]
public void Forceful_question()
{
Assert.Equal("Whoa, chill out!", Bob.Response("WHAT THE HELL WERE YOU THINKING?"));
} [Fact(Skip = "Remove to run test")]
public void Shouting_numbers()
{
Assert.Equal("Whoa, chill out!", Bob.Response("1, 2, 3 GO!"));
} [Fact(Skip = "Remove to run test")]
public void Only_numbers()
{
Assert.Equal("Whatever.", Bob.Response("1, 2, 3"));
} [Fact(Skip = "Remove to run test")]
public void Question_with_only_numbers()
{
Assert.Equal("Sure.", Bob.Response("4?"));
} [Fact(Skip = "Remove to run test")]
public void Shouting_with_special_characters()
{
Assert.Equal("Whoa, chill out!", Bob.Response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"));
} [Fact(Skip = "Remove to run test")]
public void Shouting_with_no_exclamation_mark()
{
Assert.Equal("Whoa, chill out!", Bob.Response("I HATE YOU"));
} [Fact(Skip = "Remove to run test")]
public void Statement_containing_question_mark()
{
Assert.Equal("Whatever.", Bob.Response("Ending with ? means a question."));
} [Fact(Skip = "Remove to run test")]
public void Non_letters_with_question()
{
Assert.Equal("Sure.", Bob.Response(":) ?"));
} [Fact(Skip = "Remove to run test")]
public void Prattling_on()
{
Assert.Equal("Sure.", Bob.Response("Wait! Hang on. Are you going to be OK?"));
} [Fact(Skip = "Remove to run test")]
public void Silence()
{
Assert.Equal("Fine. Be that way!", Bob.Response(""));
} [Fact(Skip = "Remove to run test")]
public void Prolonged_silence()
{
Assert.Equal("Fine. Be that way!", Bob.Response(" "));
} [Fact(Skip = "Remove to run test")]
public void Alternate_silence()
{
Assert.Equal("Fine. Be that way!", Bob.Response("\t\t\t\t\t\t\t\t\t\t"));
} [Fact(Skip = "Remove to run test")]
public void Multiple_line_question()
{
Assert.Equal("Whatever.", Bob.Response("\nDoes this cryogenic chamber make me look fat?\nno"));
} [Fact(Skip = "Remove to run test")]
public void Starting_with_whitespace()
{
Assert.Equal("Whatever.", Bob.Response(" hmmmmmmm..."));
} [Fact(Skip = "Remove to run test")]
public void Ending_with_whitespace()
{
Assert.Equal("Sure.", Bob.Response("Okay if like my spacebar quite a bit? "));
} [Fact(Skip = "Remove to run test")]
public void Other_whitespace()
{
Assert.Equal("Fine. Be that way!", Bob.Response("\n\r \t"));
} [Fact(Skip = "Remove to run test")]
public void Non_question_ending_with_whitespace()
{
Assert.Equal("Whatever.", Bob.Response("This is a statement ending with whitespace "));
}
}

C# Solution

 using System;

 /*
question: last character is '?'
answer: "Sure." yell: all characters are uppercase
answer: "Whoa, chill out!" silence: empty
answer: "Fine. Be that way!" default
answer: "Whatever" */
public static class Bob
{
public static string Response(string statement)
{
if (statement.Trim().EndsWith('?'))
{
return "Sure.";
}
if (statement.ToUpper() == statement)
{
return "Whoa, chill out!";
}
if (statement.Trim() == "")
{
return "Fine. Be that way!";
}
return "Whatever."; }
}

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. LeetCode算法题-1-bit and 2-bit Characters(Java实现)

    这是悦乐书的第302次更新,第321篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第170题(顺位题号是717).有两个特殊字符,第一个字符可以用一个比特0表示,第二个字 ...

  2. CentOS6.9安装WordPress搭建自己的博客网站

    首先说明我用的是服务器上之前装的mysql数据库,只需要配置上就行了 准备工作 CentOS6.9 在/目录下创建一个目录src,把下载的东西都放到这个文件夹下 下载Apache Httpd,下载地址 ...

  3. AI 学习路线

    [导读] 本文由知名开源平台,AI技术平台以及领域专家:Datawhale,ApacheCN,AI有道和黄海广博士联合整理贡献,内容涵盖AI入门基础知识.数据分析挖掘.机器学习.深度学习.强化学习.前 ...

  4. asp.net core 排序过滤分页组件:sieve(2)表达式树的复习

    在Sieve组件中使用了很多关于表达式树的知识,但在我们日常的工作中写表达式树的机会是非常少的,至少在我的编程生涯中没怎么写过表达式树(可能也就是3,4次).所以,为了能够看懂Sieve里面的源代码, ...

  5. [认证授权] 4.OIDC(OpenId Connect)身份认证(核心部分)

    1 什么是OIDC? 看一下官方的介绍(http://openid.net/connect/): OpenID Connect 1.0 is a simple identity layer on to ...

  6. 本地跑 spark ui 报错

    java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z at org.spark_pr ...

  7. Java的基本类型和包装类型

    测试的JDK版本:java version "1.7.0_79".Java的9中基本类型:void.char.boolean.byte.short.int.long.float.d ...

  8. HTML HTML5 新特性

    一.语义化标签 语义化标签 为页面提供了更好的页面结构. 描述 属性 <header></header>  定义文档的头部区域 <footer></foote ...

  9. Python开发【第十六篇】:AJAX全套(转)

    作者:武沛齐 出处:http://www.cnblogs.com/wupeiqi/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 概述 对于 ...

  10. webpack基本用法

    1. 压缩代码(production模式) optimization: { minimizer: [new UglifyJsPlugin({ cache: true, parallel: true, ...