Пример #1
0
        //constructor
        public MarketingFirm(ISweepstakesManager manager) //dependency injection
        {
            this.manager = manager;
            string nameOfFirm = "Name of Marketing Firm";

            name = UserInterface.GetUserInputFor(nameOfFirm);
        }
Пример #2
0
        //member methods
        public Sweepstakes CreateSweepstake()
        {
            string      sweepstakesName = "Name of Sweepstakes";
            string      userEntry       = UserInterface.GetUserInputFor(sweepstakesName);
            Sweepstakes sweepstakes     = new Sweepstakes(userEntry);

            return(sweepstakes);
        }
Пример #3
0
 public void RegisterConstestant(Contestant contestant)
 {
     contestant.FirstName          = UserInterface.GetUserInputFor("first name");
     contestant.LastName           = UserInterface.GetUserInputFor("last name");
     contestant.EmailAddress       = UserInterface.GetUserInputFor("email address");
     contestant.RegistrationNumber = contestants.Count;
     contestants.Add(contestant.RegistrationNumber, contestant);
 }
Пример #4
0
        //member methods

        public void RegisterContestant()
        {
            Contestant contestant = new Contestant();

            contestant.firstName    = UserInterface.GetUserInputFor("First Name");
            contestant.lastName     = UserInterface.GetUserInputFor("Last Name");
            contestant.emailAddress = UserInterface.GetUserInputFor("Email Address");
            string registration = UserInterface.GetUserInputFor("Registration Number");

            contestant.registrationNumber = int.Parse(registration);
            contestants.Add(contestant.registrationNumber, contestant);
        }
Пример #5
0
        //member methods
        public void CreateSweepstake()
        {
            //What is the name of the sweepstakes?
            //Read user input
            string      nameOfSweeps = UserInterface.GetUserInputFor("What is the name of the sweepstakes?");
            Sweepstakes sweepstakes  = new Sweepstakes(nameOfSweeps);

            //Add the sweepstakes to the Stack, Queue, or List
            _manager.InsertSweepstakes(sweepstakes);
            listOfSweeps.Add(sweepstakes);
            Count++;
        }
Пример #6
0
        public void PickAWinner(Random rng)
        {
            if (listOfSweeps.Count < 1)
            {
                return;
            }
            //Which sweepstakes?
            UserInterface.DisplaySweeps(listOfSweeps);
            string userInput = UserInterface.GetUserInputFor("Which sweepstakes would you like to pick a winner 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];
                        activeSweep = _manager.GetSweepstakes(userInput);
                    }
                }
                if (activeSweep == null)
                {
                    UserInterface.DisplaySweeps(listOfSweeps);
                    userInput = UserInterface.GetUserInputFor("Which sweepstakes would you like to pick a winner for?\n\nType 'cancel' to cancel...");
                }
            }
            if (userInput == "cancel")
            {
                return;
            }
            bool isEmpty = activeSweep.CheckIfContestantsIsEmpty();

            //Randomly generate int to pick contestant from dictionary based on their key
            if (isEmpty == false)
            {
                sweepWinner = activeSweep.PickWinner(rng);
            }
            else
            {
                UserInterface.DisplayContestantsIsEmptyError();
                Console.ReadKey();
                Console.Clear();
                return;
            }
            activeSweep.PrintContestantInfo(sweepWinner);
            //Notify all contestants of their win/loss
            //Integrate the mailAPI
            activeSweep.SendEmailToWinner(sweepWinner);
            activeSweep.SendEmailToLosers();
            activeSweep = null;
        }
Пример #7
0
        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;
        }
Пример #8
0
        public void CreateMarketingFirmWithManager()
        {
            string userInput = "a";

            //get user input to determine the stack or queue
            while (userInput != "s" && userInput != "q")
            {
                userInput = UserInterface.GetUserInputFor("Would you like to use the s)tack or q)ueue data structure?");
                if (userInput == "s")
                {
                    marketingFirm = new MarketingFirm(stack);
                }
                else if (userInput == "q")
                {
                    marketingFirm = new MarketingFirm(queue);
                }
            }
        }
Пример #9
0
 //Constructor
 public Contestant()
 {
     firstName    = UserInterface.GetUserInputFor("first name");
     lastName     = UserInterface.GetUserInputFor("last name");
     emailAddress = UserInterface.GetUserInputFor("email address");
 }
Пример #10
0
 //member methods (CAN DO)
 public void CreateSweepstake()
 {
     UserInterface.PromptUser("What would you like to call your sweepstake?");
     Sweepstakes newSweepstakes = new Sweepstakes(UserInterface.GetUserInputFor());
 }
Пример #11
0
 public void GetEmail()
 {
     UserInterface.PromptUser("What is your email address?");
     emailAddress = UserInterface.GetUserInputFor();
 }
Пример #12
0
 public void GetLastName()
 {
     UserInterface.PromptUser("What is your last name?");
     lastName = UserInterface.GetUserInputFor();
 }
Пример #13
0
 public void GetFirstName()
 {
     UserInterface.PromptUser("What is your first name?");
     firstName = UserInterface.GetUserInputFor();
 }