Exemple #1
0
        static void Main(string[] args)
        {
            SweepstakesManagerFactory smf = new SweepstakesManagerFactory();

            //var manager = smf.WhichManager("queue");
            UserInterface.WhichManagerQuestion();
            MarketingFirm thing    = new MarketingFirm(smf.WhichManager(UserInterface.GetResponse()));
            Sweepstakes   gotmilk  = new Sweepstakes("got milk");
            Sweepstakes   gotmilk1 = new Sweepstakes("got milk1");
            Sweepstakes   gotmilk2 = new Sweepstakes("got milk2");
            Sweepstakes   gotmilk3 = new Sweepstakes("got milk3");
            Contestant    shawn    = new Contestant();
            Contestant    domino   = new Contestant();
            Contestant    ender    = new Contestant();
            Contestant    bre      = new Contestant();

            thing.manager.InsertSweepstakes(gotmilk);
            thing.manager.InsertSweepstakes(gotmilk1);
            thing.manager.InsertSweepstakes(gotmilk2);
            gotmilk2.RegisterContestant(shawn);
            thing.manager.InsertSweepstakes(gotmilk3);
            thing.manager.InsertSweepstakes(gotmilk2);
            Sweepstakes s = thing.manager.GetSweepstakes();

            Console.ReadLine();
        }
        //    effective "run applications" class -- majority of code will be run here

        //    member variables



        //    constructor
        public MarketingFirm()
        {
            Sweepstakes sweepstakes = new Sweepstakes();
            Contestant  contestant  = new Contestant();

            sweepstakes.RegisterContestant(contestant);
            sweepstakes.PrintContestantInfo(contestant);
            sweepstakes.PickWinner();
        }
        public void CreateSweepStakes()
        {
            string      more        = "yes";
            Sweepstakes sweepstakes = new Sweepstakes(IUserInterface.SweepstakesName());

            sweepstakes.RegisterContestant(IUserInterface.GetUserInfo());
            Console.WriteLine("Do you want to enter another person? 'yes' or 'no'");
            more = Console.ReadLine();
            while (more == "yes")
            {
                sweepstakes.RegisterContestant(IUserInterface.GetUserInfo());
                manager.InsertSweepStakes(sweepstakes);
                Console.WriteLine("Do you want to enter another person? 'yes' or 'no'");
                more = Console.ReadLine();
            }
            sweepstakes.PickWinner();
            IUserInterface.AnnouceWinner(sweepstakes);
            IUserInterface.Notify(sweepstakes);
        }
Exemple #4
0
 //member methods
 public void CreateSweepstakes()
 {
     for (int j = 0; j < 3; j++)
     {
         Console.WriteLine("Enter a name for your sweepstakes:");
         Sweepstakes sweepstakes = new Sweepstakes(Console.ReadLine());
         for (int i = 0; i < 2; i++)
         {
             sweepstakes.RegisterContestant(new Contestant());
         }
         manager.InsertSweepstakes(sweepstakes);
     }
 }
        public Contestant GetNextSweepstakesWinner()
        {
            Random random = new Random();

            InsertSweepstakes(sweepstakesInfo);
            sweepstakesInfo.RegisterContestant();
            sweepstakesInfo.CreateDictionary();
            Console.WriteLine("\nStack Example:\n");
            for (int i = 0; i < sweepstakesStack.Count; i++)
            {
                int randomInt = random.Next(0, 49);
                Console.WriteLine("Winner of {0} is {1}", sweepstakesStack.ElementAt(i).sweepstakesName, sweepstakesInfo.ContestantDictionary.ElementAt(randomInt).Value.firstName);
            }
            return(null);
        }