Created
October 30, 2013 15:30
-
-
Save wendorf/7234596 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace DELETEME | |
{ | |
class Program | |
{ | |
static void Main(string[] args) { | |
Func<string, string> polite = name => { | |
if (name.Length > 4) | |
return String.Format("I like your name, {0}.", name); | |
else | |
return String.Format("Please don't tell me your nickname, '{0}'.", name); | |
}; | |
Func<string, string> mean = name => { | |
if (name.Length > 4) | |
return String.Format("You have a terrible name, {0}.", name); | |
else | |
return String.Format("Wow, tough guy, aren't you '{0}'?", name); | |
}; | |
var moods = new Func<string, string>[] { | |
name => { | |
if (name.Length > 4) | |
return String.Format("I am robot number one. I have met you, {0}.", name); | |
else | |
return String.Format("You cannot fool robot number one, '{0}'.", name); | |
}, | |
name => { | |
if (name.Length > 4) | |
return String.Format("I am robot number two. You are pleased to meet my acquaintance, {0}.", name); | |
else | |
return String.Format("I am immune to your short-circuit attempts, '{0}'.", name); | |
} | |
}; | |
rollCall(polite); | |
rollCall(mean); | |
foreach (var mood in moods) { | |
rollCall(mood); | |
} | |
} | |
static void rollCall(Func<string, string> mood) { | |
string name; | |
while ((name = prompt()) != "exit") { | |
Console.WriteLine(mood(name)); | |
Console.WriteLine(); | |
} | |
} | |
static string prompt() { | |
Console.Write("What is your name? "); | |
return Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment