示例#1
0
        /*
         * Welcome message
         * Directions
         * Choose a machine
         * Place a bet
         * Pull lever
         * Randomly rolls around and gives you
         * Machine tells you if you won or not
         */
        static void Main(string[] args)
        {
            SlotMachine myMachine = new SlotMachine(); // 3 slots, 5 icons per slot

            Console.WriteLine("\n\nWelcome to ¢heapE slots!\n");

            Console.WriteLine("This is a simple penny slot machine. Place your wager and win BIG!!!\n\n");

            while (true)
            {
                // place a bet
                Console.WriteLine("Please enter your wager in pennies.");

                // You could get this using:
                // int userBet = Convert.ToInt32(Console.ReadLine());
                // myMachine.CurrentBet = userBet;
                myMachine.CurrentBet = Convert.ToInt32(Console.ReadLine());

                // pull the lever
                Console.WriteLine("Press enter to pull the lever");
                Console.ReadKey(); // TODO Later: make this actually look for ENTER
                myMachine.PullLever();

                // display the results
                int[] tempResults = myMachine.GetResults();
                for (int i = 0; i < tempResults.Length; i++)
                {
                    Console.Write(tempResults[i] + " ");
                }

                // payout
                Console.WriteLine("You won {0} pennies!", myMachine.GetPayout());
            }
        }
示例#2
0
        /*
         * Welcome message
         * Directions
         * Choose a machine
         * Place a bet
         * Pull lever
         * Randomly rolls around and gives you
         * Machine tells you if you won or not
         */
        static void Main(string[] args)
        {
            SlotMachine myMachine = new SlotMachine(); // 3 slots, 5 icons per slot

            Console.WriteLine("Welcome to slots!");

            Console.WriteLine("Directions");

            while (true)
            {
                // place a bet
                Console.WriteLine("Type in how many pennies to bet");

                // You could get this using:
                // int userBet = Convert.ToInt32(Console.ReadLine());
                // myMachine.CurrentBet = userBet;
                myMachine.CurrentBet = Convert.ToInt32(Console.ReadLine());

                // pull the lever
                Console.WriteLine("Press enter to pull the lever");
                Console.ReadKey(); // TODO Later: make this actually look for ENTER
                myMachine.PullLever();

                // display the results
                int[] tempResults = myMachine.GetResults();
                for (int i = 0; i < tempResults.Length; i++)
                {
                    Console.Write(tempResults[i] + " ");
                }

                // payout
                Console.WriteLine("You won {0} pennies!", myMachine.GetPayout());
            }
        }
示例#3
0
        private static void Main(string[] args)
        {
            CompositionContainer container = GetConfiguredContainer();
            SlotMachine          slot      = container.GetExportedValue <SlotMachine>();

            Play(slot);
            Console.WriteLine("Thanks for playing, come back when you have more money!");
        }
示例#4
0
        public SlotMachineApp()
        {
            int spins = 1;

            SS = new SlotSetup();
            SM = new SlotMachine(SS.Reels, SS.SlotCount);
            SC = new SlotCalc(SS.Reels, SS.SymbolCountPerReel1, SS.WinningCombinations, SS.WinningCombinationsPayout);
        }
示例#5
0
        private static void Main(string[] args)
        {
            IUnityContainer container = GetConfiguredContainer();
            SlotMachine     slot      = container.Resolve <SlotMachine>();

            Play(slot);
            Console.WriteLine("Thanks for playing, come back when you have more money!");
        }
示例#6
0
        /*
         * Welcome message
         * Directions
         * Choose a machine
         * Place a bet
         * Pull lever
         * Randomly rolls around and gives you
         * Machine tells you if you won or not
         */
        static void Main(string[] args)
        {
            double      GameCounter = 0, WinCounter = 0;
            SlotMachine myMachine = new SlotMachine(); // 3 slots, 5 icons per slot

            Console.WriteLine("Welcome to slots!");

            Console.WriteLine("Directions");

            while (true)
            {
                GameCounter++;
                // place a bet
                Console.WriteLine("Type in how many pennies to bet");

                // You could get this using:
                // int userBet = Convert.ToInt32(Console.ReadLine());
                // myMachine.CurrentBet = userBet;
                myMachine.CurrentBet = Convert.ToInt32(Console.ReadLine());

                // pull the lever
                Console.WriteLine("Press enter to pull the lever");
                Console.ReadKey(); // TODO Later: make this actually look for ENTER
                myMachine.PullLever();

                // display the results
                int[] tempResults = myMachine.GetResults();
                for (int i = 0; i < tempResults.Length; i++)
                {
                    Console.Write(tempResults[i] + " ");
                }

                // payout
                if (myMachine.GetPayout() > 0)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("You won {0} pennies!", myMachine.GetPayout());
                    Console.ResetColor();
                    WinCounter++;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("You won {0} pennies!", myMachine.GetPayout());
                    Console.ResetColor();
                }

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Your win percentage: {0}/{1} = {2:P2}", WinCounter, GameCounter, myMachine.GetWinPrecentage(WinCounter, GameCounter));
                Console.ResetColor();
            }
        }
示例#7
0
        /*
         * Welcome message
         * Directions
         * Choose a machine
         * Place a bet
         * Pull lever
         * Randomly rolls around and gives you
         * Machine tells you if you won or not
         */
        static void Main(string[] args)
        {
            SlotMachine myMachine = new SlotMachine(); // 3 slots, 5 icons per slot

            Console.WriteLine("Welcome to slots!");

            Console.WriteLine("Directions");

            while (true)
            {
                // place a bet
                Console.WriteLine("Type in how many pennies to bet or enter 0 to exit: ");

                // You could get this using:
                // int userBet = Convert.ToInt32(Console.ReadLine());
                // myMachine.CurrentBet = userBet;
                myMachine.CurrentBet = Convert.ToInt32(Console.ReadLine());

                // if zero pennies then leave the program
                if (myMachine.CurrentBet == 0)
                {
                    break;
                }

                // pull the lever
                Console.WriteLine("Press enter to pull the lever");
                Console.ReadKey(); // TODO Later: make this actually look for ENTER
                myMachine.PullLever();

                // display the results
                int[] tempResults = myMachine.GetResults();
                Console.ForegroundColor = ConsoleColor.Red;
                for (int i = 0; i < tempResults.Length; i++)
                {
                    Console.Write(tempResults[i] + " ");
                }
                Console.ForegroundColor = ConsoleColor.White;

                // payout
                Console.WriteLine();
                if (myMachine.GetPayout() == 0)
                {
                    Console.WriteLine("Sorry you did not win, try again!", myMachine.GetPayout());
                }
                else
                {
                    decimal penniesInDollars = myMachine.GetPayout() / 100;
                    Console.WriteLine("You won $ {0} ", penniesInDollars);
                }
            }
        }
示例#8
0
        public static void Play(SlotMachine slot)
        {
            string option;

            do
            {
                Console.WriteLine("Type \"M\" to add money, \"S\" to spin, or \"Q\" to quit");
                option = Console.ReadLine();

                if (option.StartsWith("M", StringComparison.CurrentCultureIgnoreCase))
                {
                    slot.AddMoney(100);
                }
                else if (option.StartsWith("S", StringComparison.CurrentCultureIgnoreCase))
                {
                    slot.Spin();
                }
                else if (!option.StartsWith("Q", StringComparison.CurrentCultureIgnoreCase))
                {
                    Console.WriteLine("I don't understand.");
                }
            } while (!option.StartsWith("Q", StringComparison.CurrentCultureIgnoreCase));
        }