Basic 001 Bob
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的更多相关文章
- 从零开始PHP攻略(001)——Bob的汽车零部件商店
1.创建订单表单 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- PHP7 扩展之自动化测试
在安装 PHP7 及各种扩展的过程中,如果你是用源码安装,会注意到在 make 成功之后总会有一句提示:Don't forget to run 'make test'. 这个 make test 就是 ...
- Hexo 下 Markdown 的配置与学习
本篇 更换 Hexo 下的 Markdown 渲染插件 学习 Markdown 基本语法 ✎更换 Markdown 渲染插件 ✎原因 Hexo 内置的默认渲染插件是 hexo-renderer-mar ...
- TypeScript学习指南第一章--基础数据类型(Basic Types)
基础数据类型(Basic Types) 为了搭建应用程序,我们需要使用一些基础数据类型比如:numbers,strings,structures,boolean等等. 在TypeScript中除了Ja ...
- 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 ...
- 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 ...
- 《Visual Basic开发实战1200例》包括第I卷、第II卷共计1200个例子,本书是第I卷,共计600个例子。
本书以开发人员在项目开发中经常遇到的问题和必须掌握的技术为中心,介绍了应用Visual Basic进行程序开发各个方面的知识和技巧.主要包括基础知识.窗体界面设计.控件应用等.全书分6篇20章,共计6 ...
- PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642 题目描述: 拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下: 每 ...
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
随机推荐
- wordpress如何利用插件添加优酷土豆等视频到自己的博客上
wordpress有时候需要添加优酷.土豆等网站的视频到自己的博客上,传统的分享方法不能符合电脑端和手机端屏幕大小的需求,又比较繁琐,怎样利用插件的方法进行添加呢,本视频向你介绍一款这样的插件——Sm ...
- 元数据Metadata
元数据是什么? 元数据(Metadata),又称中介数据.中继数据,为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置.历史数据. ...
- ckeditor django admin 中使用
ckeditor settings配置 ############ # CKEDITOR # ############ MEDIA_ROOT = os.path.join(BASE_DIR, 'medi ...
- CSAPP:第十一章 网络编程
CSAPP:第十一章 网络编程 11.1 客户端服务器模型11.2 全球IP因特网11.3 套接字接口 11.1 客户端服务器模型 每个网络应用都是基于客户端-服务器模型.采用这个模型,一个应用是 ...
- Net core 关于缓存的实现
在很多项目中, 需要用到缓存,借鉴网上前辈们的一些经验,自己再进行总结简化了一些, 做出如下的缓存操作,其中包含内存缓存(IMemoryCache) 和 Redis 缓存; 一.前提内容, 导入两个包 ...
- java基础-04泛型
介绍 泛型就是数据类型的参数化表示,泛型的本质是参数化类型,常用E代表任何数据类型,在实际使用的时候把实际的数据类型传递给E. 泛型的好处是设计通用的功能,多个数据类型可以共用. 泛型类型E只能代表O ...
- iptables之语法
一iptables概念 防火墙分类 分为硬件防火墙和软件防火墙 硬件防火墙一般放在外网的最前面,公司的拓扑的最外面 iptables虽然称为防火墙,但是不能当做整个公司的出口防火墙,和动戈几千万,几百 ...
- 第二部分之Redis服务器(第十四章)
Redis服务器复制和多个客户端建立网络连接,处理客户端发送的命令请求,在数据库中保存客户端执行命令所产生的数据. 一,命令请求的执行过程 客户端向服务器发送命令请求 set key value 服务 ...
- AngularJS路由变化 监听方法
#使用AngularJS时,当路由发生改变时,我们需要做某些处理,此时可以监听路由事件,常用的是$routeStartChange, $routeChangeSuccess ##使用场景:在路由配置文 ...
- [ffmpeg] 解码API
版本迭代 ffmpeg解码API经过了好几个版本的迭代,上一个版本的API是 解码视频:avcodec_decode_video2 解码音频:avcodec_decode_audio4 我们现在能看到 ...