Need Help on Exquisite Corpse project in C#

Hey I have a problem on the project [Exquisite Corpse project in C#]

So i have my code here, and it return me an error when i do dotnet run “error CS0161: ‘Program.BuildACreature(string, string, string)’: not all code paths return a value” i dont understand where i did this mistake and i dont find anything on internet helping me… if you have some solutions it would be awesome.

Blockquote

using System;

namespace ExquisiteCorpse
{
class Program
{
static void Main(string args)
{
BuildACreature(“ghost”, “monster”, “bug”);
}

static string BuildACreature(string head, string body, string feet)
{
switch (head)
{
case "ghost":
GhostHead();
break;
case "bug":
BugHead();
break;
case "monster":
MonsterHead();
break;
default:
Console.WriteLine("■■■■■■■");
break;
} 
switch (body)
{
case "ghost":
GhostBody();
break;
case "bug":
BugBody();
break;
case "monster":
MonsterBody();
break;
default:
Console.WriteLine("■■■■■■■");
break;
} 
   switch (feet)
{
case "ghost":
GhostFeet();
break;
case "bug":
BugFeet();
break;
case "monster":
MonsterFeet();
break;
default:
Console.WriteLine("■■■■■■■");
break;
}
}

static void GhostHead()
{
  Console.WriteLine("     ..-..");
  Console.WriteLine("    ( o o )");
  Console.WriteLine("    |  O  |");
}

static void GhostBody()
{
  Console.WriteLine("    |     |");
  Console.WriteLine("    |     |");
  Console.WriteLine("    |     |");
}

static void GhostFeet()
{
  Console.WriteLine("    |     |");
  Console.WriteLine("    |     |");
  Console.WriteLine("    '~~~~~'");
}

static void BugHead()
{
  Console.WriteLine("     /   \\");
  Console.WriteLine("     \\. ./");
  Console.WriteLine("    (o + o)");
}

static void BugBody()
{
  Console.WriteLine("  --|  |  |--");
  Console.WriteLine("  --|  |  |--");
  Console.WriteLine("  --|  |  |--");
}

static void BugFeet()
{
  Console.WriteLine("     v   v");
  Console.WriteLine("     *****");
}

static void MonsterHead()
{
  Console.WriteLine("     _____");
  Console.WriteLine(" .-,;='';_),-.");
  Console.WriteLine("  \\_\\(),()/_/");
  Console.WriteLine("   (,___,)");
}

static void MonsterBody()
{
  Console.WriteLine("   ,-/`~`\\-,___");
  Console.WriteLine("  / /).:.('--._)");
  Console.WriteLine(" {_[ (_,_)");
}

static void MonsterFeet()
{
  Console.WriteLine("    |  Y  |");
  Console.WriteLine("   /   |   \\");
  Console.WriteLine("   \"\"\"\" \"\"\"\"");
}

}
}

Blockquote

ok i finally found the mistake on the first method it was void and not string as it return a void… !

1 Like

Can you post the working code so I can see the difference please?

Thanks!

here on this line
“static string BuildACreature(string head, string body, string feet)”

its void and not string

1 Like