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. js 学习之路10:try异常处理和第一个js小程序

    try 语句测试代码块的错误. catch 语句处理错误. throw 语句创建自定义错误. 1. try/catch语句 catch语句用来捕获try代码块中的错误,并执行自定义的语句来处理它. 语 ...

  2. CG-CTF simple-machine

    运行一下,输入flag: 用ida打开: input_length和input_byte_804B0C0为重命名的变量:现在一个个看调用的函数. sub_8048526(): 这个函数使用了mmap分 ...

  3. 使用bootstrap的dropdown部件时报错:error:Bootstrap dropdown require Popper.js

    前言:前端小白一枚,刚注册博客,先发个学习过程中新碰到小问题试试水吧~ 摘要:最近在学习bootstrap,偶然碰到了一个小问题,bootstrap网站也没有做过多的解释,今天分享给大家. 问题描述: ...

  4. 功能测试话题分享-0323 Bug

  5. Git + Docker + Jenkins自动化部署web到Linux(Centos)

    1.把代码托管到Github上 2.安装Docker 3.安装Jenkins 4.在项目中编写Dockerfile.publish.sh (1)Dockerfile内容 # 基于dotnet基础环境构 ...

  6. npm基本操作(安装,搭建环境,打包)

    Nodejs(npm)环境安装: npm的安装配置(从nodejs网站上安装npm): Windows安装Nodejs操作步骤如下: 64 位安装包下载地址 : https://nodejs.org/ ...

  7. 网页控制脚本修改系统信息 C语言调用uci

    0 交叉编译生成程序 http://tuntuntun.net/%E5%9C%A8OpenWrt%E4%B8%8A%E8%BF%90%E8%A1%8C%E7%AC%AC%E4%B8%80%E4%B8% ...

  8. 利用 keras_proprecessing.image 扩增自己的遥感数据(多波段)

    1.keras 自带的 keras_proprecessing.image 只支持三种模式图片(color_mode in ['grey', 'RGB', 'RGBA'])的随机扩增. 2.遥感数据除 ...

  9. Ubuntu server 16.04的安装 以及配置(服务器版)

    1.在电脑上下载最新版本的Ubuntu服务器ISO映像,刻录到CD或创建一个可启动的USB盘. 2.视情况而定,进入到服务器的boot界面,把cd或者usb设置为启动第一项 3.开始安装   1)Ub ...

  10. 初识Haskell 二:基本操作符、类型Type、数据结构

    对Discrete Mathematics Using a Computer的第一章Introduction to Haskell进行总结.环境Windows 1. 在安装了ghci后,便可以进行Ha ...