Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string hairColour = string.Empty;
- string jobType = string.Empty;
- string raceType = string.Empty;
- int intRace = 0;
- int intHair = 0;
- int intJob = 0;
- bool validUserInput1 = false;
- bool validUserInput2 = false;
- bool validUserInput3 = false;
- while (validUserInput1 == false)
- {
- try
- {
- Console.WriteLine("Please choose a race. 1 = Human. 2 = Dwarf. 3 = Elf.");
- intRace = int.Parse(Console.ReadLine()); //try to parse string as int variable
- }
- catch (Exception) { } //catch invalid input exception
- if ((intRace >= 1) && (intRace <= 3)) //ensure entered int is >= 1 but <=3
- { validUserInput1 = true; }
- else { Console.WriteLine("Invalid Input. "); }
- }
- Console.WriteLine("You have selected " + intRace);
- while (validUserInput2 == false)
- {
- try
- {
- Console.WriteLine("Please choose your hair colour. 1 = Brown. 2 = Blonde. 3 = Red.");
- intHair = int.Parse(Console.ReadLine()); //try to parse string as int variable
- }
- catch (Exception) { } //catch invalid input exception
- if ((intHair >= 1) && (intHair <= 3)) //ensure entered int is >= 1 but <=3
- { validUserInput2 = true; }
- else { Console.WriteLine("Invalid Input. "); }
- }
- Console.WriteLine("You have selected " + intHair);
- while (validUserInput3 == false)
- {
- try
- {
- Console.WriteLine("Please choose your job. 1 = Warrior. 2 = Mage. 3 = Thief.");
- intJob = int.Parse(Console.ReadLine()); //try to parse string as int variable
- }
- catch (Exception) { } //catch invalid input exception
- if ((intJob >= 1) && (intJob <= 3)) //ensure entered int is >= 1 but <=3
- { validUserInput3 = true; }
- else { Console.WriteLine("Invalid Input. "); }
- }
- Console.WriteLine("You have selected " + intJob);
- if (intHair == 1)
- {
- hairColour = "brown";
- }
- else if (intHair == 2)
- {
- hairColour = "blonde";
- }
- else if (intHair == 3)
- {
- hairColour = "red";
- }
- if (intRace == 1)
- {
- raceType = "human";
- }
- else if (intRace == 2)
- {
- raceType = "dwarf";
- }
- else if (intRace == 3)
- {
- raceType = "elf";
- }
- if (intJob == 1)
- {
- jobType = "Warrior";
- }
- else if (intJob == 2)
- {
- jobType = "Mage";
- }
- else if (intJob == 3)
- {
- jobType = "Thief";
- }
- Console.WriteLine("You have chosen to be a " + hairColour + "-haired " + raceType + " " + jobType + ".");
- Console.WriteLine("Press any key to terminate");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement