Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Plan your Heist!");
            Console.WriteLine();
            //declare variable  Create a way to store a single team member. A team member will have a name, a skill Level and a courage factor. The skill Level will be a positive integer and the courage factor will be a decimal between 0.0 and 2.0.
            Heister teamMember;

            //Prompt the user to enter a team member's name and save that name.
            Console.WriteLine("What is the team member's name?");
            string name = Console.ReadLine();

            //Prompt the user to enter a team member's skill level and save that skill level with the name.
            Console.WriteLine("What is the team member's skill level?");
            string skillLevelString = Console.ReadLine();
            int    skillLevel;

            try
            {
                //put thing that might throw an exception in here
                skillLevel = int.Parse(skillLevelString);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{skillLevelString} is not a valud skill level. Using a default value of 10");
                skillLevel = 10;
            }

            //Prompt the user to enter a team member's courage factor and save that courage factor with the name.
            Console.WriteLine("What is the team member's courage factor?");
            string  courageFactorString = Console.ReadLine();
            decimal courageFactor;

            //set up try catch w/ this too

            try
            {
                courageFactor = decimal.Parse(courageFactorString);
            }
            catch (Exception)
            {
                Console.WriteLine($"{courageFactorString} is not a valid courgae factor. Using a default value of 1");
                courageFactor = 1.0M;
            }

            //what is value of team member rn?
            //nothing yet.. havent set it to anything

            teamMember = new Heister()
            {
                Name          = name,
                SkillLevel    = skillLevel,
                CourageFactor = courageFactor,
            };
            Console.WriteLine($"Name: {teamMember.Name}");
            Console.WriteLine($"Skill Level: {teamMember.SkillLevel}");
            Console.WriteLine($"Courage Factor: {teamMember.CourageFactor}");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Plan Your Heist");
            Console.WriteLine();
            Heister teamMember;

            Console.WriteLine("What is the team member's name?");
            string name = Console.ReadLine();

            Console.WriteLine("What is the team member's skill level?");
            string skillLevelString = Console.ReadLine();
            int    skillLevel;

            try
            {
                skillLevel = int.Parse(skillLevelString);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{skillLevelString} is not a valid skill level. Using a default value of 10");
                skillLevel = 10;
            }

            Console.WriteLine("What is the team member's courage factor?");
            string  courageFactorString = Console.ReadLine();
            decimal courageFactor;

            try
            {
                courageFactor = decimal.Parse(courageFactorString);
            }
            catch (Exception)
            {
                Console.WriteLine($"{courageFactorString} is not a valid courage factor. Using a default value of 1.0");
                courageFactor = 1.0M;
            }

            teamMember = new Heister()
            {
                Name          = name,
                SkillLevel    = skillLevel,
                CourageFactor = courageFactor
            };

            Console.WriteLine($"Name: {teamMember.Name}");
            Console.WriteLine($"Skill Level: {teamMember.SkillLevel}");
            Console.WriteLine($"Courage Factor: {teamMember.CourageFactor}");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Phase 1
            Console.WriteLine("Plan Your Heist!");
            Console.WriteLine();

            //Create a way to store a single team member. A team member will have a name, a skill Level and a courage factor. The skill Level will be a positive integer and the courage factor will be a decimal between 0.0 and 2.0.

            Heister teamMember;

            //Prompt the user to enter a team member's name and save that name.
            Console.WriteLine("Enter your team member's name");
            string name = Console.ReadLine();

            // teamMember.Add("Name", name);

            //Prompt the user to enter a team member's skill level and save that skill level with the name.
            Console.WriteLine("Enter your team member's skill level");
            string skillLevelString = Console.ReadLine();

            int skillLevel;

            try
            {
                skillLevel = int.Parse(skillLevelString);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{skillLevelString} is not a valid skill level.  Using a default value of 10");
                skillLevel = 10;
                throw;
            }


            //Prompt the user to enter a team member's courage factor and save that courage factor with the name.
            Console.WriteLine("Enter your team member's courage factor");
            string  courageFactorString = Console.ReadLine();
            decimal courageFactor;

            try
            {
                courageFactor = decimal.Parse(courageFactorString);
            }
            catch (Exception)
            {
                Console.WriteLine($"{courageFactorString} is not a valid courage factor. Using a default value of 1.0");
                courageFactor = 1.0M;
            }


            //Display the team member's information.
            teamMember = new Heister()
            {
                Name          = name,
                SkillLevel    = skillLevel,
                CourageFactor = courageFactor
            };

            Console.WriteLine($"Name: {teamMember.Name}");
            Console.WriteLine($"Skill Level: {teamMember.SkillLevel}");
            Console.WriteLine($"Courage Factor: {teamMember.CourageFactor}");

            //Display the team member's information.
            // foreach (KeyValuePair<string, string> attribute in teamMember)
            // {
            //     Console.WriteLine($"{attribute.Key}: {attribute.Value}");
            // }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Plan Your Heist");
            Console.WriteLine();
            Console.WriteLine("Enter bank difficulty.");
            int bankDifficulty = int.Parse(Console.ReadLine());

            // Heister teamMember;

            // Create a way to store several team members.
            List <Heister> NewHeisters = new List <Heister>();

            bool wantsToAddName = true;

            while (wantsToAddName)
            {
                Heister NewHeister = new Heister();

                Console.WriteLine("What is the team member's name?");
                string name = Console.ReadLine();
                // Stop collecting team members when a blank name is entered.
                if (name == "")
                {
                    NewHeister = null;
                    break;
                }
                else
                {
                    NewHeister.Name = name;
                }
                bool hasValidSkillLevel = false;
                while (!hasValidSkillLevel)
                {
                    Console.WriteLine("What's your tema member's skill level?");
                    string skillLevelString = Console.ReadLine();
                    try
                    {
                        NewHeister.SkillLevel = int.Parse(skillLevelString);
                        hasValidSkillLevel    = true;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine($"{skillLevelString} is not a valid skill level.");
                    }
                }
                bool hasValidCourageFactor = false;
                while (!hasValidCourageFactor)
                {
                    Console.WriteLine("What's your team member's courage factor?");
                    string courageFactorString = Console.ReadLine();


                    try
                    {
                        NewHeister.CourageFactor = decimal.Parse(courageFactorString);
                        hasValidCourageFactor    = true;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine($"{courageFactorString} is not a valid courage factor.");
                    }

                    NewHeisters.Add(NewHeister);
                }
            }
            // Display a message containing the number of members of the team.
            Console.WriteLine(NewHeisters.Count);

            // Display each team member's information.

            Console.Clear();

            foreach (Heister TeamMember in NewHeisters)
            {
                Console.WriteLine($"Name: {TeamMember.Name} Skill Level: {TeamMember.SkillLevel} Courage Factor: {TeamMember.CourageFactor}");
            }

            // Stop displaying each team member's information.

            Console.ReadLine();
            Console.Clear();


            // After the user enters the team information, prompt them to enter the number of trial runs the program should perform.
            Console.WriteLine("Enter in trial runs");
            int trialRun  = int.Parse(Console.ReadLine());
            int Successes = 0;
            int Failures  = 0;


            int combineSkillLevel = 0;

            foreach (Heister item in NewHeisters)
            {
                combineSkillLevel += item.SkillLevel;
            }



            for (int i = 0; i < trialRun; i++)
            {
                Random rand         = new Random();
                int    randomNumber = rand.Next(-10, 10);
                bankDifficulty += randomNumber;
                int bankTotal = bankDifficulty + randomNumber;
                if (combineSkillLevel >= bankDifficulty)
                {
                    Successes += 1;
                }
                else
                {
                    Failures += 1;
                }
            }
            Console.Clear();
            Console.WriteLine($"Successes: {Successes}");
            Console.WriteLine($"Failures: {Failures}");
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Plan Your Heist");
            Console.WriteLine();
            Heister teamMember;

            // Create a way to store several team members.
            List <Heister> heistGroup = new List <Heister>();

            Console.WriteLine("What is the team member's name?");
            string name = Console.ReadLine();

            Console.WriteLine("What is the team member's skill level?");
            string skillLevelString = Console.ReadLine();
            int    skillLevel;

            try
            {
                skillLevel = int.Parse(skillLevelString);
            }
            catch (Exception)
            {
                Console.WriteLine($"{skillLevelString} is not a valid skill level. Using a default value of 10");
                skillLevel = 10;
            }

            Console.WriteLine("What is the team member's courage factor?");
            string  courageFactorString = Console.ReadLine();
            decimal courageFactor;

            try
            {
                courageFactor = decimal.Parse(courageFactorString);
            }
            catch (Exception)
            {
                Console.WriteLine($"{courageFactorString} is not a valid courage factor. Using a default value of 1.0");
                courageFactor = 1.0M;
            }

            teamMember = new Heister()
            {
                Name          = name,
                SkillLevel    = skillLevel,
                CourageFactor = courageFactor
            };
            Console.WriteLine($"Name: {teamMember.Name}");
            Console.WriteLine($"Skill Level: {teamMember.SkillLevel}");
            Console.WriteLine($"Courage Factor: {teamMember.CourageFactor}");
            heistGroup.Add(teamMember);



            while (true)
            {
                Console.WriteLine("Enter a new team member's name!");
                string memberName = Console.ReadLine();

                if (name == "")
                {
                    break;
                }
                else
                {
                    Console.WriteLine("What is your skill level");
                    string skill = Console.ReadLine();

                    Console.WriteLine("What is your courage factor");
                    string courage = Console.ReadLine();
                }


                List <int> skillNum = new List <int>();

                heistGroup.ForEach(heister =>
                {
                    skillNum.Add(heister.SkillLevel);
                });
                int skillSum       = skillNum.Sum();
                int bankDifficulty = 100;

                if (skillSum < bankDifficulty)
                {
                    Console.WriteLine("I wouldn't do this");
                }
                else
                {
                    Console.WriteLine("I think you can pull this off");
                }
                //phase 4 started
                Random random    = new Random();
                int    luckValue = random.Next(-10, 10);
                bankDifficulty += luckValue;
                Console.WriteLine($"Your teams skill level is {skillSum}");
                Console.WriteLine($"The bank's difficulty level is {bankDifficulty}");
            }
        }