C# Methods - Exquisite Corpse - Code Review/Feedback

Hi everyone,

I’m very new to coding (and I am quite an old man) so I am having a fun but also intensely challenging time learning how to code. I am able to do most of the lessons and projects by following the instructions but I don’t know if I’ll ever be able to build by own apps or code my own programs. Hopefully one day this will all click!

Anyway, to the nitty gritty of it all. I have just finished the Methods in C# and was working on the Exquisite Corpse project: https://www.codecademy.com/courses/learn-c-sharp/projects/csharp-exquisite-corpse

I was attempting the bonus challenges at the bottom to make a mode where users can choose whether or not to randomise or build their own characters from scratch. The bonus challenge asks us to:

“Add a starting mode, so a user can select whether to randomly generate a creature or create one manually.”

I am looking for some feedback on this build. I feel like the main string looks super messy when I created the user input section. Does this look like poor practice? Is there some way to tidy it up to make it look nicer? Any feedback would be greatly appreciated. Thank you for your time.

using System; namespace ExquisiteCorpse { class Program { static void Main(string[] args) { Console.WriteLine("Welcome to exquisite corpse! Would you like to create a random monster or build your own?"); string randomOrBuild = Console.ReadLine(); switch(randomOrBuild) { case "random": Console.WriteLine("Here is your random creature!"); RandomMode(); break; case "build": Console.WriteLine("Please choose \"ghost\", \"monster\" or \"bug\"!"); Console.WriteLine("Choose your head: "); string choiceOne = Console.ReadLine().ToLower(); Console.WriteLine("Choose your body: "); string choiceTwo = Console.ReadLine().ToLower(); Console.WriteLine("Choose your feet: "); string choiceThree = Console.ReadLine().ToLower(); BuildACreature(choiceOne, choiceTwo, choiceThree); break; } } static void BuildACreature(string head, string body, string feet) { int headNum = TranslateToNumber(head); int bodyNum = TranslateToNumber(body); int feetNum = TranslateToNumber(feet); SwitchCase(headNum, bodyNum, feetNum); } static void SwitchCase(int head, int body, int feet) { switch(head) { case 1: GhostHead(); break; case 2: MonsterHead(); break; case 3: BugHead(); break; } switch(body) { case 1: GhostBody(); break; case 2: MonsterBody(); break; case 3: BugBody(); break; } switch(feet) { case 1: GhostFeet(); break; case 2: MonsterFeet(); break; case 3: BugFeet(); break; } } static int TranslateToNumber(string creature) { switch(creature) { case "ghost": return 1; case "monster": return 2; case "bug": return 3; default: return 1; } } static void RandomMode() { Random randomNumber = new Random(); int head = randomNumber.Next(1, 4); int body = randomNumber.Next(1, 4); int feet = randomNumber.Next(1, 4); SwitchCase(head, body, feet); } 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(" \"\"\"\" \"\"\"\""); } } }

P.S. - Methods has given me a lot of headaches and I’ve heard this is supposed to be one of the easier parts of learning coding haha

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.