public void RegisterAContestant(Random rng) { if (listOfSweeps.Count < 1) { return; } //Which sweepstakes? string userInput; UserInterface.DisplaySweeps(listOfSweeps); userInput = UserInterface.GetUserInputFor("Which sweepstakes would you like to register a contestant for?\n\nType 'cancel' to cancel..."); while (activeSweep == null && userInput != "cancel") { for (int i = 0; i < listOfSweeps.Count; i++) { if (listOfSweeps[i].Name == userInput) { activeSweep = listOfSweeps[i]; } } if (activeSweep == null) { UserInterface.DisplaySweeps(listOfSweeps); userInput = UserInterface.GetUserInputFor("Which sweepstakes would you like to register a contestant for?\n\nType 'cancel' to cancel..."); } } if (userInput == "cancel") { return; } //Ask if you would like to manually add one or generate random contestants do { userInput = UserInterface.DisplayMenu("What would you like to do?\n\na) Add one contestant\nb) Generate 50 random contestants\nc) Done registering contestants"); if (Comparer <string> .Default.Compare(userInput, "a") == 0) { //Manually add one contestant string firstName = UserInterface.GetUserInputFor("What is the contestant's first name?"); string lastName = UserInterface.GetUserInputFor("What is the contestant's last name?"); string emailAddress = UserInterface.GetUserInputFor("What is the contestant's email address?"); Contestant newContestant = new Contestant(firstName, lastName, emailAddress, idIncrementer++); activeSweep.RegisterContestant(newContestant); } if (Comparer <string> .Default.Compare(userInput, "b") == 0) { RegisterRandomContestants(rng); } } while (Comparer <string> .Default.Compare(userInput, "c") != 0); activeSweep = null; }
//member methods public void RunSimulation() { string userInput; CreateMarketingFirmWithManager(); do { userInput = UserInterface.DisplayMenu("What would you like to do?\n\na) Create Sweepstake\nb) Pick Winner\nc) Add contestant\nd) Quit"); if (Comparer <string> .Default.Compare(userInput, "a") == 0) { marketingFirm.CreateSweepstake(); } if (Comparer <string> .Default.Compare(userInput, "b") == 0) { marketingFirm.PickAWinner(rng); } if (Comparer <string> .Default.Compare(userInput, "c") == 0) { marketingFirm.RegisterAContestant(rng); } } while (Comparer <string> .Default.Compare(userInput, "d") != 0); }