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. 最广泛使用的是基本验证 ( ...
随机推荐
- Web前端教程4-JQuery教程
目录 1. JQuery基础 1.1. 基本语法 1.2. JQ和JS的差异 1.3. JQ入口函数的写法 1.4. JQ核心函数 1.5. JQ对象 2. JQ静态和实例方法 2.1. JQ静态方法 ...
- 【Teradata SQL】行转列函数TDStats.udfConcat
TDstats.udfConcat为Teradata自带UDF,定义如下: show function tdstats.udfconcat; REPLACE FUNCTION tdstats.UDFC ...
- vue笔记未整理
全局组件 局部组件 子组件传值到父组件 父子组件传值 watch跟计算属性差不多,都会有缓存,计算属性优先 计算属性get set 对象 数组 对象 数组 不复用 改变数组 直接修改数组,页面没变化 ...
- kvm虚拟化
1.kvm虚拟化介绍 什么是虚拟化 虚拟化就是通过模拟计算机硬件(cpu,内存,硬盘,网卡)来实现在一台物理服务器上运行同时多个不同的操作系统,并且使每个操作系统之间都是互相隔离的 为什么要学习虚拟化 ...
- Django学习笔记(2)--视图函数
用pycharm打开FDJ项目 URL分发器 视图: 视图一般都写在app的view,py中.并且视图的第一个参数永远都是request(一个HttpRequest)对象.这个对象存储了请求过来的所有 ...
- python上下文管理
一.python上下文介绍: python中的上下文,指的就是代码所执行的环境状态,或者运行的场景 python上下文管理器规定了某个对象的使用范围,当进入或者离开了使用范围,会有相应的操作,多用于资 ...
- C语言报错:error: expected ‘while’ at end of input } ^
在建线程池过程当中遇见上图所示错误: 解决方法: Linux中定义: SYNOPSIS #include <pthread.h> void pthread_cleanup_push(voi ...
- Web项目中的 /
如果 / 出现在路径的前面: web.xml中:http://loclalhost:8080/项目名称/ 在项目的根路径下面 jsp中: http://localhost:8080/ ...
- VS2019 离线安装方法详解
本文详细介绍了 VS2019 离线安装的相关步骤,以桌面开发为主下载 C++桌面开发..NET 桌面开发相关的工作负载.MFC 可选组件及帮助查看器. 工作负载(Workload) 离线安装需要先根据 ...
- Flutter绘制波浪
以上动画是仿照 里面的物理动画还未仿写 代码见 https://github.com/dnoyeb/syk_flutter