Answer to Question #20877 in C# for novice

Question #20877
I am currently using c# 2010 to do a sort of sim person.he eats, exercises, checks health level, ect. but its not graphic. But I cant find whats not working here is the code the first one is the main program the second one is using a class for access modifiers.Thank you.p using System; using System.Collections.Generic; using System.Linq; using System.Text; using ConsoleApplication1; namespace critter { class Program { static void Main(string[] args) { human select=new human(); while (true) { select.Health(); Console.WriteLine("(1) health level"); Console.WriteLine("(2) tiredness level"); Console.WriteLine("(3) hungriness level"); Console.WriteLine("(4) sleep"); Console.WriteLine("(5) eat"); Console.WriteLine("(6) exercise"); Console.WriteLine("(7) exit"); Console.Read();
Expert's answer
You must check the entered value. For example:
Console.WriteLine("(7) exit");
int x = Console.Read();
char ch = Convert.ToChar(x);
if (ch == '7') break;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog