The Name Game: Difference between revisions
Content added Content deleted
(Added d) |
|||
Line 122: | Line 122: | ||
Shirley! |
Shirley! |
||
</pre> |
</pre> |
||
=={{header|C#|C sharp}}== |
|||
{{trans|Java}} |
|||
<lang csharp>using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
namespace TheNameGame { |
|||
class Program { |
|||
static void PrintVerse(string name) { |
|||
StringBuilder sb = new StringBuilder(name.ToLower()); |
|||
sb[0] = Char.ToUpper(sb[0]); |
|||
string x = sb.ToString(); |
|||
string y = "AEIOU".IndexOf(x[0]) > -1 ? x.ToLower() : x.Substring(1); |
|||
string b = "b" + y; |
|||
string f = "f" + y; |
|||
string m = "m" + y; |
|||
switch (x[0]) { |
|||
case 'B': |
|||
b = y; |
|||
break; |
|||
case 'F': |
|||
f = y; |
|||
break; |
|||
case 'M': |
|||
m = y; |
|||
break; |
|||
} |
|||
Console.WriteLine("{0}, {0}, bo-{1}", x, b); |
|||
Console.WriteLine("Banana-fana fo-{0}", f); |
|||
Console.WriteLine("Fee-fi-mo-{0}", m); |
|||
Console.WriteLine("{0}!", x); |
|||
Console.WriteLine(); |
|||
} |
|||
static void Main(string[] args) { |
|||
List<string> nameList = new List<string>() { "Gary", "Earl", "Billy", "Felix", "Mary", "Steve" }; |
|||
nameList.ForEach(PrintVerse); |
|||
} |
|||
} |
|||
}</lang> |
|||
{{out}} |
|||
<pre>Gary, Gary, bo-bary |
|||
Banana-fana fo-fary |
|||
Fee-fi-mo-mary |
|||
Gary! |
|||
Earl, Earl, bo-bearl |
|||
Banana-fana fo-fearl |
|||
Fee-fi-mo-mearl |
|||
Earl! |
|||
Billy, Billy, bo-illy |
|||
Banana-fana fo-filly |
|||
Fee-fi-mo-milly |
|||
Billy! |
|||
Felix, Felix, bo-belix |
|||
Banana-fana fo-elix |
|||
Fee-fi-mo-melix |
|||
Felix! |
|||
Mary, Mary, bo-bary |
|||
Banana-fana fo-fary |
|||
Fee-fi-mo-ary |
|||
Mary! |
|||
Steve, Steve, bo-bteve |
|||
Banana-fana fo-fteve |
|||
Fee-fi-mo-mteve |
|||
Steve!</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |