コード例 #1
0
        // constructor

        // Member methods
        // Sweepstakes manager factory.
        public ISweepstakesManager GetSweepstakesManager(string type)
        {
            ISweepstakesManager sweepstakesManager;

            switch (type)
            {
            case "stack":
                sweepstakesManager = new SweepstakesStackManager();
                break;

            case "queue":
                sweepstakesManager = new SweepstakesQueueManager();
                break;

            default:
                throw new ApplicationException(string.Format("Not a valid Sweepstakes Manager Type"));
            }

            return(sweepstakesManager);
        }
コード例 #2
0
        public static ISweepstakesManager ChooseManager()
        {
            ISweepstakesManager manager;
            string choice = UserInterface.ChooseStackOrQueue();

            if (choice == "queue")
            {
                manager = new SweepstakesQueueManager();
                return(manager);
            }
            else if (choice == "stack")
            {
                manager = new SweepstakesStackManager();
                return(manager);
            }
            else
            {
                return(ChooseManager());
            }
        }
コード例 #3
0
        public void CreateMarketingFirmWithManager()
        {
            string userSelectedManager = UserInterface.GetUserInput("Press 0 for stack manager or 1 for queue manager");

            if (userSelectedManager == "0")
            {
                SweepstakesStackManager stackManager  = new SweepstakesStackManager();
                MarketingFirm           marketingFirm = new MarketingFirm(stackManager);
            }
            else if (userSelectedManager == "1")
            {
                SweepstakesQueueManager queueManager  = new SweepstakesQueueManager();
                MarketingFirm           marketingFirm = new MarketingFirm(queueManager);
            }
            else
            {
                Console.WriteLine("Please make a valid selection");
                CreateMarketingFirmWithManager();
            }
        }
コード例 #4
0
        public ISweepstakesManager CreateSweepstakesManager()
        {
            string prompt    = "would you like a stack or queue manager? type 'stack' for stack, any other entry will return a queue.";
            string userInput = UserInterface.GetUserInputForStringPrompt(prompt);

            switch (userInput)
            {
            case "stack":
                stack = new SweepstakesStackManager("stack");
                return(stack);

                break;

            default:
                queue = new SweepstakesQueueManager("queue");
                return(queue);

                break;
            }
        }
コード例 #5
0
        public static MarketingFirm MarketingFirmFactory(string storageMethod)
        {
            UserInterface.ChooseStorage();

            ISweepstakesManager manager;

            if (storageMethod == "queue")
            {
                manager = new SweepstakesQueueManager();
            }
            else if (storageMethod == "stack")
            {
                manager = new SweepstakesStackManager();
            }
            else
            {
                //could throw exception to handle this
                return(null);
            }
            return(new MarketingFirm(manager));
        }
コード例 #6
0
        public static ISweepstakesManager ChooseManager()
        {
            string userInput;
            ISweepstakesManager manager = null;

            Console.WriteLine("Choose which style of sweepstakes manager you would like to use\nChoose Queue or Stack");
            userInput = Console.ReadLine().ToLower();
            switch (userInput)
            {
            case "queue":
                manager = new SweepstakesQueueManager();
                return(manager);

            case "stack":
                manager = new SweepstakesStackManager();
                return(manager);

            default:
                return(ChooseManager());
            }
        }
コード例 #7
0
        public void SweepstakesManagerFactory()
        {
            Console.WriteLine("Would you like to manage the sweepstakes with a queue or a stack?");
            factoryChoice = Console.ReadLine();

            switch (factoryChoice)
            {
            case "queue":
                queueManage      = new SweepstakesQueueManager();
                newMarketingFirm = new MarketingFirm(queueManage);
                break;

            case "stack":
                stackManage      = new SweepstakesStackManager();
                newMarketingFirm = new MarketingFirm(stackManage);
                break;

            default:
                Console.WriteLine("Wrong input");
                break;
            }
        }
コード例 #8
0
        public static ISweepstakesManager CreateManager()
        {
            string choice = UserInterface.GetManagerType();
            ISweepstakesManager manager = null;

            switch (choice)
            {
            case "stack":
                manager = new SweepstakesStackManager();
                break;

            case "queue":
                manager = new SweepstakesQueueManager();
                break;

            default:
                Console.WriteLine("Not a valid manager type.");
                CreateManager();
                break;
            }
            return(manager);
        }
コード例 #9
0
        public ISweepstakesManager ChooseManager()
        {
            ISweepstakesManager manager = null;

            Console.WriteLine("Please choose a stack or queue sweepstakes manager. Enter 'stack or 'queue'");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
            case "stack":
                manager = new SweepstakesStackManager();
                return(manager);

            case "queue":
                manager = new SweepstakesQueueManager();
                return(manager);

            default:
                ChooseManager();
                break;
            }
            return(manager);
        }
コード例 #10
0
        public void CreateMarketingFirmWithManager()
        {
            Console.WriteLine("Enter marketing firm name:  ");
            name = Console.ReadLine();
            Console.WriteLine("Tye preferred manager, stack or queue, then hit enter:  ");
            managerChoice = Console.ReadLine();
            ISweepstakesManager manager = null;

            switch (managerChoice)
            {
            case "stack":
                manager = new SweepstakesStackManager();
                break;

            case "queue":
                manager = new SweepstakesQueueManager();
                break;

            default:
                break;
            }
            MarketingFirm newFirm = new MarketingFirm(manager);
        }
コード例 #11
0
        public static ISweepstakesManager CreateManagementSystem(string choice)
        {
            ISweepstakesManager sweepstakesManager;

            sweepstakesManager = null;

            switch (choice)
            {
            case "1":
                sweepstakesManager = new SweepstakesStackManager();
                break;

            case "2":
                sweepstakesManager = new SweepstakesQueueManager();
                break;

            default:
                Console.WriteLine("Invalid input.");
                break;
            }

            return(sweepstakesManager);
        }
コード例 #12
0
        static public ISweepstakesManager PickManager()
        {
            ISweepstakesManager manager;

            Console.WriteLine("Choose what SweepstakesManager\n 1.)Stack\n 2.)Queue");
            int.TryParse(Console.ReadLine(), out int input);

            switch (input)
            {
            case 1:
                manager = new SweepstakesStackManager();
                break;

            case 2:
                manager = new SweepstakesQueueManager();
                break;

            default:
                manager = PickManager();
                break;
            }
            return(manager);
        }
コード例 #13
0
        public void CreateMarketingFirmWithManager()
        {
            Console.WriteLine("Please choose a stack or queue manager.");
            string input = Console.ReadLine();
            ISweepstakesManager manager = null;

            switch (input)
            {
            case "Stack":
                Console.WriteLine("You Chose Stack Manager");
                manager = new SweepstakesStackManager();
                break;

            case "Queue":
                Console.WriteLine("You Chose Queue Manager");
                manager = new SweepstakesQueueManager();
                break;

            default:
                Console.WriteLine("Please Choose Stack or Queue");
                break;
            }
            MarketingFirm marketingFirm = new MarketingFirm(manager);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            SweepstakesQueueManager queueManager = new SweepstakesQueueManager();
            SweepstakesStackManager stackManager = new SweepstakesStackManager();

            Sweepstakes sweepstakes = new Sweepstakes("Noah's Ark Giveaway");

            CreateDefaultContestants(sweepstakes);

            queueManager.InsertSweepstakes(sweepstakes);
            stackManager.InsertSweepstakes(sweepstakes);

            sweepstakes = new Sweepstakes("Crazy Bob's Fireworks Giveaway");
            CreateDefaultContestants(sweepstakes);

            queueManager.InsertSweepstakes(sweepstakes);
            stackManager.InsertSweepstakes(sweepstakes);

            sweepstakes = new Sweepstakes("Library Donation Giveaway");
            CreateDefaultContestants(sweepstakes);

            queueManager.InsertSweepstakes(sweepstakes);
            stackManager.InsertSweepstakes(sweepstakes);

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine($"Running contest number {i+1}:");
                Console.WriteLine("Queue Manager:");
                RunSweepstakes(queueManager);
                Console.WriteLine("Stack Manager:");
                RunSweepstakes(stackManager);
                Console.WriteLine();
            }

            Console.ReadLine();
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: adamfollmer/WeekOfApril4
        static void Main(string[] args)
        {
            SweepstakesQueueManager queueManager = new SweepstakesQueueManager();
            SweepstakesStackManager stackManager = new SweepstakesStackManager();

            Sweepstakes thousandDollar = new Sweepstakes("Thousand Dollars!");
            Sweepstakes hundredDollar  = new Sweepstakes("Hundred Dollars!");
            Sweepstakes millionDollar  = new Sweepstakes("Million Dollars!");
            Sweepstakes billionDollar  = new Sweepstakes("Billion Dollars!");

            queueManager.InsertSweepstakes(thousandDollar);
            queueManager.InsertSweepstakes(millionDollar);

            stackManager.InsertSweepstakes(billionDollar);
            stackManager.InsertSweepstakes(hundredDollar);

            Contestant one   = new Contestant("Adam", "Milwaukee", "5555555");
            Contestant two   = new Contestant("Marco", "Milwaukee", "5555555");
            Contestant three = new Contestant("Mike", "Milwaukee", "5555555");
            Contestant four  = new Contestant("Brad", "Milwaukee", "5555555");
            Contestant five  = new Contestant("Jared", "Milwaukee", "5555555");
            Contestant six   = new Contestant("Jim", "Milwaukee", "5555555");
            Contestant seven = new Contestant("Andrew", "Milwaukee", "5555555");
            Contestant eight = new Contestant("Ian", "Milwaukee", "5555555");

            thousandDollar.RegisterContestant(one);
            thousandDollar.RegisterContestant(two);
            thousandDollar.RegisterContestant(three);
            thousandDollar.RegisterContestant(four);
            thousandDollar.RegisterContestant(five);
            thousandDollar.RegisterContestant(six);
            thousandDollar.RegisterContestant(seven);
            thousandDollar.RegisterContestant(eight);

            millionDollar.RegisterContestant(one);
            millionDollar.RegisterContestant(two);
            millionDollar.RegisterContestant(three);
            millionDollar.RegisterContestant(four);
            millionDollar.RegisterContestant(five);
            millionDollar.RegisterContestant(six);
            millionDollar.RegisterContestant(seven);
            millionDollar.RegisterContestant(eight);

            hundredDollar.RegisterContestant(one);
            hundredDollar.RegisterContestant(two);
            hundredDollar.RegisterContestant(three);
            hundredDollar.RegisterContestant(four);

            billionDollar.RegisterContestant(five);
            billionDollar.RegisterContestant(six);
            billionDollar.RegisterContestant(seven);
            billionDollar.RegisterContestant(eight);

            thousandDollar.RegisterContestant(eight);
            Console.WriteLine();

            Sweepstakes nextContest = queueManager.PeekNext();
            string      winner1     = queueManager.GetNextSweepstakesWinner().PickWinner();

            Console.WriteLine("The winner of the {0} sweepstakes is {1}", nextContest.Name, winner1);
            Console.WriteLine();

            nextContest = stackManager.PeekNext();
            winner1     = stackManager.GetNextSweepstakesWinner().PickWinner();
            Console.WriteLine("The winner of the {0} sweepstakes is {1}", nextContest.Name, winner1);
            Console.WriteLine();

            nextContest = queueManager.PeekNext();
            winner1     = queueManager.GetNextSweepstakesWinner().PickWinner();
            Console.WriteLine("The winner of the {0} sweepstakes is {1}", nextContest.Name, winner1);
            Console.WriteLine();

            nextContest = stackManager.PeekNext();
            winner1     = stackManager.GetNextSweepstakesWinner().PickWinner();
            Console.WriteLine("The winner of the {0} sweepstakes is {1}", nextContest.Name, winner1);
            Console.WriteLine();
            Console.ReadLine();
        }
コード例 #16
0
        public static SweepstakesQueueManager UseQueue()
        {
            SweepstakesQueueManager queue = new SweepstakesQueueManager();

            return(queue);
        }
コード例 #17
0
ファイル: ManagerFactory.cs プロジェクト: flyerb/Sweepstakes
        //ctor

        public ManagerFactory()
        {
            stack = new SweepstakesStackManager();
            queue = new SweepstakesQueueManager();
        }