static void Main(string[] args) { Console.WriteLine("Plan your Heist!"); Console.WriteLine("Choose your bank Difficulty: "); int BankDifficulty = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter Team Member's name"); string newName = Console.ReadLine(); int newSkillLevel = new int(); double newCourageFactor = new double(); Team heistTeam = new Team(); while (newName != "") { Console.Write($"Enter {newName}'s skill level: "); newSkillLevel = Int32.Parse(Console.ReadLine()); while (newSkillLevel < 0) { Console.WriteLine("Skill level has to be a postive number, please try again."); Console.Write($"Enter {newName}'s skill level: "); newSkillLevel = Int32.Parse(Console.ReadLine()); } Console.Write($"Enter {newName}'s courage level: "); newCourageFactor = Convert.ToDouble(Console.ReadLine()); while (newCourageFactor > 2.0 || newCourageFactor < 0) { Console.WriteLine("Courage can't be higher than 2 or less than 0, please try again."); Console.Write($"Enter {newName}'s courage level: "); newCourageFactor = Int32.Parse(Console.ReadLine()); } TeamMember newTeamMember = new TeamMember() { Name = newName, SkillLevel = newSkillLevel, CourageFactor = newCourageFactor }; heistTeam.AddTeamMember(newTeamMember); Console.WriteLine("---------------"); Console.Write("Enter Next Team Member's name: "); newName = Console.ReadLine(); } List <TeamMember> teamNames = heistTeam.getTeamMembers(); // Console.WriteLine(""); // Console.WriteLine($"Your heist team has {heistTeam.teamCount} members."); // Console.WriteLine("Your team members are:"); // foreach (var member in teamNames) // { // Console.WriteLine($@" // Team Member {teamNames.IndexOf(member) + 1} // {member.Name} // ------------- // Skill Level : {member.SkillLevel} // Courage Factor: {member.CourageFactor} // "); // } int CombinedSkill = heistTeam.getTotalSkill(); Console.Write("How many heists? "); int numTrialRuns = Int32.Parse(Console.ReadLine()); int counter = 1; int goodRuns = 0; int badRuns = 0; while (numTrialRuns > 0) { Random rand = new Random(); //Random is a data type! creates a new Random class int LuckValue = rand.Next(-10, 11); //gets you a non-negative random integer between 1 and 100 BankDifficulty = BankDifficulty + LuckValue; Console.WriteLine($"Run #{counter}"); Console.Write($"The team's combined skill level is {CombinedSkill}."); Console.Write($"The bank's difficulty level is {BankDifficulty}."); Console.WriteLine(); if (BankDifficulty <= CombinedSkill) { Console.WriteLine("Bank heist is successful."); goodRuns++; } else { Console.WriteLine("Team goes to jail."); badRuns++; } numTrialRuns--; counter++; } Console.WriteLine($"{goodRuns} successful run{(goodRuns != 1 ? "s" : "")}. {badRuns} bad run{(badRuns != 1 ? "s" : "")}."); }
static void Main(string[] args) { Console.WriteLine("Plan your Heist!"); //determing bank difficultly level int bankLevel = 0; bool enteringBank = true; while (enteringBank) { Console.WriteLine("Enter the bank's difficulty level: "); Console.Write(" > "); string bankLevelInput = Console.ReadLine(); try { bankLevel = int.Parse(bankLevelInput); enteringBank = false; } catch { Console.WriteLine("Must be an integer. Press any key to try again..."); Console.ReadKey(); Console.Clear(); } } TeamMember newUser = new TeamMember() { Name = TeamMember.UserName(), SkillLevel = TeamMember.UserSkillLevel(), CourageFactor = TeamMember.UserCourageFactor(), }; newUser.DisplayMemberInfo(); //Create new Heist Team Members Hacker Rio = new Hacker(); Rio.Name = "Rio"; Rio.SkillLevel = 100; Hacker Tokyo = new Hacker(); Tokyo.Name = "Tokyo"; Tokyo.SkillLevel = 100; LockSpecialist Nairobi = new LockSpecialist(); Nairobi.Name = "Nairobi"; Nairobi.SkillLevel = 100; LockSpecialist Berlin = new LockSpecialist(); Berlin.Name = "Berlin"; Berlin.SkillLevel = 100; Muscle Denver = new Muscle(); Denver.Name = "Denver"; Denver.SkillLevel = 100; Muscle Oslo = new Muscle(); Oslo.Name = "Oslo"; Oslo.SkillLevel = 100; List <IRobber> rolodex = new List <IRobber>() { Rio, Tokyo, Nairobi, Berlin, Denver, Oslo }; // Things start here theres a user input called 'value' List <int> options = new List <int>() { 1, 2, 3 }; { //what is this number suppose to be? string value = Console.ReadLine(); bool success = Int32.TryParse(value, out int result); while (!success && !options.Contains(result)) { Console.WriteLine($"{value} is an invalid option. Please enter a number: _"); string userInputRedux = Console.ReadLine(); success = Int32.TryParse(userInputRedux, out result); } // things end here while (true) { Console.WriteLine($"{rolodex.Count} members of the team."); Console.WriteLine(""); Console.Write("Would you like to add a new person? (hit enter for no)"); string answer = Console.ReadLine(); if (string.IsNullOrWhiteSpace(answer)) { break; } Console.Write("Enter the Name of Possible New Member of the crew: "); string NameOfPossibleNewMember = Console.ReadLine(); Console.WriteLine($"What specialty does {NameOfPossibleNewMember} have?"); Console.WriteLine("-------------------------------------"); Console.WriteLine(" 1. Hacker (Disabled Alarms) "); Console.WriteLine(" 2. Muscle (Disarms Guards) "); Console.WriteLine(" 3. Lock Specialists (Cracks Vault) "); Console.WriteLine("-------------------------------------"); Console.Write("Enter the number: "); int specialty = Int32.Parse(Console.ReadLine()); Console.Write($"What skill level does {NameOfPossibleNewMember} have? (1-100): "); int skill = Int32.Parse(Console.ReadLine()); Console.Write($"What percentage of the cut does {NameOfPossibleNewMember} want? (1-100): "); int cut = Int32.Parse(Console.ReadLine()); //check the specialty interger switch (specialty) { case 1: rolodex.Add(new Hacker() { Name = NameOfPossibleNewMember, SkillLevel = skill, PercentageCut = cut }); break; case 2: rolodex.Add(new Muscle() { Name = NameOfPossibleNewMember, SkillLevel = skill, PercentageCut = cut }); break; case 3: rolodex.Add(new LockSpecialist() { Name = NameOfPossibleNewMember, SkillLevel = skill, PercentageCut = cut }); break; } //create a new bank with the min and max preset Bank newBank = new Bank() { AlarmSound = new Random().Next(0, 100), VaultScore = new Random().Next(0, 100), SecurityGuardScore = new Random().Next(0, 100), CashOnHand = new Random().Next(50000, 1000000), }; } } }
static void Main(string[] args) { Console.WriteLine("Plan Your Heist!"); //https://gist.github.com/askingalot/aa1877148da3f3fef98ddcd17410834e List <TeamMember> team = new List <TeamMember>(); //our list now contains teammembers class Console.Write("Bank Difficulty> "); int bankDifficulty = int.Parse(Console.ReadLine()); Console.WriteLine(); //get the first team members name Console.Write("Name> "); string name = Console.ReadLine(); //must have name outside the loop //check to see if its empty, create the dictionary for new team member and add them to the team. prepare for another loop so we ask for another name while (name != "") //when no name is entered its false { Console.Write("Skill Level> "); string skillLevel = (Console.ReadLine()); Console.Write("Courage factor> "); string courageFactor = (Console.ReadLine()); //returns a string and parse it into double parse and return a number TeamMember member = new TeamMember(); member.Name = name; member.SkillLevel = int.Parse(skillLevel); member.CourageFactor = double.Parse(courageFactor); team.Add(member); //get the next team member's name Console.WriteLine(); Console.Write("Name> "); name = Console.ReadLine(); } Console.WriteLine(); // Console.WriteLine($"Team Size: {team.Count}"); //count is the size. how many people on the team Console.WriteLine("Number of runs>"); int trialRunCount = int.Parse(Console.ReadLine()); Console.WriteLine(); //add up the skill level int teamSkill = 0; //keeps track of skill level outside the loop foreach (TeamMember member in team) //gives me access to each member one at a time { teamSkill += member.SkillLevel; //add to the existing skill varaiable of the entire team } HeistReport report = new HeistReport(); //constructor created the new report, if i wanted to add capabilities into this class then i'd need a class. this stores the successcount and failurecount for (int i = 0; i < trialRunCount; i++) //we wrapped code below in for loop. every time through the loop i'll get a new luckvalue and bank difficulty { Random generator = new Random(); //phase 4 gets random number int luckValue = generator.Next(-10, 11); //takes minval and maxvalue // int bankDifficulty = 100; //needed to bring this down from the top as well now we move it back up. int trialRunBankDifficulty = bankDifficulty += luckValue; //add luckvalue to bankdifficulty and set the value -- then set this to a variable. Console.WriteLine($"Team Skil level: {teamSkill}"); Console.WriteLine($"Bank Difficulty: {trialRunBankDifficulty}"); if (trialRunBankDifficulty > teamSkill) //did the team do better than the bank difficulty level? { Console.WriteLine("Your heist failed :("); report.FailureCount++; //add one to it, increment it } else { Console.WriteLine("You are rich!"); //run it and see if you failed or not report.SuccessCount++; } } //the report we are printing out. report.Print(); // Console.WriteLine(); // Console.WriteLine("Heist results"); // Console.WriteLine("-------------"); // Console.WriteLine($"Successes: {report.SuccessCount}"); // Console.WriteLine($"Failures: {report.FailureCount}"); // Console.WriteLine(); // Console.WriteLine(); // foreach (Dictionary<string, string> member in team) // { // Console.WriteLine("-----------"); // Console.WriteLine($"Name: {member["Name"]}"); // Console.WriteLine($"Skill: {member["SkillLevel"]}"); // Console.WriteLine($"Courage: {member["CourageFactor"]}"); // } }
static void Main(string[] args) { //Create a way to store several team members. var wholeTeam = new List <TeamMember>(); var newTeamMember = new TeamMember(); //Create a random number between -10 and 10 for the heist's luck value. var luckValue = new Random().Next(-10, 11); //Print the message "Plan Your Heist!". Console.WriteLine("Plan Your Heist!"); Console.WriteLine(); //Store a value for the bank's difficulty level Console.Write("Enter bank's difficulty level: "); int bankDifficultyLevel = int.Parse(Console.ReadLine()); //Store a value trial runs Console.Write("Enter the number of trial runs the program should perform: "); int trailRuns = int.Parse(Console.ReadLine()); int count = 0; int successfulRun = 0; int failedRun = 0; while (count < trailRuns) { //Collect several team members' information. wholeTeam.Clear(); // clear for new team Console.WriteLine(); Console.WriteLine($"New Trail Run"); Console.Write("Add A New Member? Y/N "); string answer = Console.ReadLine().ToLower(); Console.WriteLine(); while (answer == "y") { newTeamMember = CreateTeamMember(); //Stop collecting team members when a blank name is entered. if (!string.IsNullOrEmpty(newTeamMember.Name)) { wholeTeam.Add(newTeamMember); Console.WriteLine(); Console.Write("Add A New Member? Y/N "); answer = Console.ReadLine().ToLower(); Console.WriteLine(); } else { Console.WriteLine(@"Error Member Must have name try again NAMELESS MEMBER WAS NOT ADDED"); } } //Sum the skill levels of the team. Save that number. IEnumerable <int> total = wholeTeam.Select(member => member.SkillLevel); int teamTotalSkillLevel = total.Sum(); //Before displaying the success or failure message, display team's combined skill level and bank's difficulty level Console.WriteLine($"Team Cobined Skill Level: {teamTotalSkillLevel}"); Console.WriteLine($"Bank Difficulty Level: { bankDifficultyLevel + luckValue}"); //Compare the number with the bank's difficulty level. If the team's skill level is greater than or equal to the bank's difficulty level, Display a success message, otherwise display a failure message. if (teamTotalSkillLevel >= bankDifficultyLevel + luckValue) { Console.WriteLine("Money! Money! Money! Monday!"); successfulRun++; } else { Console.WriteLine("Being Free anb broke is better than jail and broke."); failedRun++; } count++; } Console.WriteLine($@" Sucessful Runs: {successfulRun} Failed Runs: {failedRun}"); }
static void Main(string[] args) { Console.WriteLine("Plan Your Heist!"); List <TeamMember> team = new List <TeamMember>(); Console.WriteLine("Bank Difficulty> "); int bankDifficulty = int.Parse(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Name> "); string name = Console.ReadLine(); while (name != "") { Console.WriteLine("Skill Level> "); string skillLevel = Console.ReadLine(); Console.WriteLine("Courage Factor> "); string courageFactor = Console.ReadLine(); TeamMember member = new TeamMember(); member.Name = name; member.SkillLevel = int.Parse(skillLevel); member.CourageFactor = double.Parse(courageFactor); team.Add(member); Console.WriteLine(); // get the next team member Console.WriteLine("Name> "); name = Console.ReadLine(); } Console.WriteLine(); Console.WriteLine("Number of runs> "); int trialRunCount = int.Parse(Console.ReadLine()); Console.WriteLine(); int teamSkill = 0; foreach (TeamMember member in team) { teamSkill += member.SkillLevel; } HeistReport report = new HeistReport(); for (int i = 0; i < trialRunCount; i++) { Random generator = new Random(); int luckValue = generator.Next(-10, 11); int trialRunBankDifficulty = bankDifficulty + luckValue; Console.WriteLine($"Team Skill Level: {teamSkill}"); Console.WriteLine($"Bank Difficulty: {trialRunBankDifficulty}"); if (teamSkill >= trialRunBankDifficulty) { Console.WriteLine("YOU RICH!"); report.SuccessCount++; } else { Console.WriteLine("Failure..."); report.FailureCount++; } report.Print(); } }
static void Main(string[] args) { Console.WriteLine("Plan Your Heist!"); List <TeamMember> team = new List <TeamMember>(); Console.Write("Bank Difficulty> "); int bankDifficulty = int.Parse(Console.ReadLine()); Console.WriteLine(); // Get first team member's name Console.Write("Name> "); string name = Console.ReadLine(); while (name != "") { Console.Write("Skill level> "); string skillLevel = Console.ReadLine(); Console.Write("Courage factor> "); string courageFactor = Console.ReadLine(); TeamMember member = new TeamMember(); member.Name = name; member.SkillLevel = int.Parse(skillLevel); member.CourageFactor = double.Parse(courageFactor); team.Add(member); Console.WriteLine(); // Get next team member's name Console.Write("Name> "); name = Console.ReadLine(); } Console.WriteLine($"Team Size: {team.Count}"); Console.WriteLine(); Console.WriteLine("Enter number of trial runs>"); int trialRunCount = int.Parse(Console.ReadLine()); Console.WriteLine(); // Determine total skill level of the team and compare it to the bank's difficulty level int teamSkill = 0; foreach (TeamMember member in team) { teamSkill += member.SkillLevel; } HeistReport report = new HeistReport(); for (int i = 0; i < trialRunCount; i++) { // Create a random number between -10 and 10 for the heist's luck value. Add this number to the bank's difficulty level. Random generator = new Random(); int luckValue = generator.Next(-10, 11); int trialRunBankDifficulty = bankDifficulty + luckValue; Console.WriteLine($"Team Skill Level: {teamSkill}"); Console.WriteLine($"Bank Difficulty Level: {trialRunBankDifficulty}"); if (trialRunBankDifficulty > teamSkill) { report.FailureCount++; } else { report.SuccessCount++; } Console.WriteLine("---------------------------"); } Console.WriteLine(); Console.WriteLine("Heist Results:"); Console.WriteLine($"Successes: {report.SuccessCount}"); Console.WriteLine($"Failures: {report.FailureCount}"); Console.WriteLine("---------------------------"); }
static void Main(string[] args) { Console.WriteLine("Plan Your Heist!"); List <TeamMember> teamMembers = new List <TeamMember>(); var difficultyLevel = new Bank(); Console.WriteLine("Enter the difficulty level for the bank."); difficultyLevel.BankDifficultyLevel = int.Parse(Console.ReadLine()); while (true) { Console.WriteLine("Please enter a team member's first name."); var teamMemberName = Console.ReadLine(); if (teamMemberName == "") { break; } Console.WriteLine("Please enter team member's skill level between 0 to 50."); var teamMemberSkillLevel = int.Parse(Console.ReadLine()); while (teamMemberSkillLevel < 0) { Console.WriteLine("Sorry, please enter a skill level between 0 to 50."); teamMemberSkillLevel = int.Parse(Console.ReadLine()); } Console.WriteLine("Please enter team member's courage factor between 0.0 to 2.0."); var teamMemberCourageFactor = decimal.Parse(Console.ReadLine()); while (teamMemberCourageFactor < 0.0m || teamMemberCourageFactor > 2.0m) { Console.WriteLine("Sorry, please enter a skill level between 0.0 to 2.0."); teamMemberCourageFactor = decimal.Parse(Console.ReadLine()); } var teamMember = new TeamMember { Name = teamMemberName, SkillLevel = teamMemberSkillLevel, CourageFactor = teamMemberCourageFactor }; teamMembers.Add(teamMember); } Console.WriteLine("Please enter number of trial runs."); var trialRuns = int.Parse(Console.ReadLine()); var successfulRuns = 0; var failedRuns = 0; for (int i = 0; i < trialRuns; i++) { var outcome = difficultyLevel.RobBank(teamMembers); if (outcome) { successfulRuns += 1; } else { failedRuns += 1; } } Console.WriteLine($"There have been a {successfulRuns} number of successful runs and {failedRuns} number of failed runs."); var numOfMembers = teamMembers.Count(); Console.WriteLine($"there are {numOfMembers} members"); //foreach (var teamMember in teamMembers) //{ // Console.WriteLine($"{teamMember.Name} has a skill level of {teamMember.SkillLevel} and courage factor of {teamMember.CourageFactor}"); //} }
public void AddTeamMember(TeamMember newMember) { _team.Add(newMember); }
static void Main(string[] args) { Console.WriteLine("Plan your heist!"); var teamMembers = new List <TeamMember>(); var newBank = new Bank(); Console.WriteLine("Please enter the difficulty level of the bank."); var difficultyLevel = int.Parse(Console.ReadLine()); newBank.BankDifficulty = difficultyLevel; while (true) { Console.WriteLine("Please enter the team member's first name."); var teamMemberName = Console.ReadLine(); if (teamMemberName == "") { break; } Console.WriteLine("Please enter the team member's skill level as an integer from 0 to 50."); var teamMemberSkillLevel = int.Parse(Console.ReadLine()); Console.WriteLine("Please enter the team member's courage factor as a decimal 0.0-2.0."); var teamMemberCourageFactor = decimal.Parse(Console.ReadLine()); var teamMember = new TeamMember { Name = teamMemberName, SkillLevel = teamMemberSkillLevel, CourageFactor = teamMemberCourageFactor }; teamMembers.Add(teamMember); } Console.WriteLine("Please enter the number of trial runs this app should execute."); var trialRuns = int.Parse(Console.ReadLine()); var successfulRuns = 0; var failedRuns = 0; for (int i = 0; i < trialRuns; i++) { var outcome = newBank.TryRob(teamMembers); if (outcome) { successfulRuns++; } else { failedRuns++; } } /*var numOfMembers = teamMembers.Count(); * Console.WriteLine($"There are {numOfMembers} members"); * * foreach (var teamMember in teamMembers) * { * Console.WriteLine($"{teamMember.Name} has a skill level of {teamMember.SkillLevel} and courage factor of {teamMember.CourageFactor}."); * }*/ Console.WriteLine($"You succeeded {successfulRuns} times and failed {failedRuns} times."); }