Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SimpleSlotMachine slotMachine = BuildMachine();

            Console.WriteLine("Welcome to the Simple Slot Machine");
            string userCommand;

            Console.WriteLine("Please enter deposit");
            decimal deposit = TryParseInputToDecimal(Console.ReadLine());

            slotMachine.EnterDeposit(new Money(deposit));

            do
            {
                Console.WriteLine($"Your balance is {slotMachine.Balance.Amount}");
                Console.WriteLine("Now stake some money");
                decimal stake = TryParseInputToDecimal(Console.ReadLine());
                slotMachine.StakeMoney(new Money(stake));
                Console.WriteLine($"Your balance is {slotMachine.Balance.Amount}");

                slotMachine.Play();


                if (slotMachine.Balance.Amount == 0)
                {
                    Console.WriteLine();
                    Console.WriteLine("Your deposit finished. Goodbye");
                    return;
                }

                Console.WriteLine("Do you want to continue? yes/no");
                userCommand = Console.ReadLine();
            }while (userCommand == continueCommand);
        }
Exemplo n.º 2
0
        static SimpleSlotMachine  BuildMachine()
        {
            var random  = new RandomValueGenerator();
            var symbols = new List <ISymbol>()
            {
                new Apple(),
                new Banana(),
                new Pineapple(),
                new Wildcard(),
            };
            var engine  = new SimpleEngine(symbols, random);
            var machine = new SimpleSlotMachine(engine);

            return(machine);
        }
Exemplo n.º 3
0
        public void User_win_money_when_winning_combinantion_appear()
        {
            //Arrange
            decimal deposit = 200;
            decimal stake   = 10;
            var     engine  = new Mock <ISimpleEngine>();

            engine.Setup(x => x.SpinTheReel()).Returns(WinCombinationApples);
            var slotMachine = new SimpleSlotMachine(engine.Object);

            //Act
            slotMachine.EnterDeposit(new Money(deposit));
            slotMachine.StakeMoney(new Money(stake));
            slotMachine.Play();

            //Assert
            slotMachine.Balance.Amount.Should().BeGreaterThan(deposit - stake);
        }
Exemplo n.º 4
0
        public void User_win_less_than_stake_when_won_with_one_wildcard_only()
        {
            //Arrange
            decimal deposit = 200;
            decimal stake   = 10;
            var     engine  = new Mock <ISimpleEngine>();

            engine.Setup(x => x.SpinTheReel()).Returns(WinCombinationWildCards);
            var slotMachine = new SimpleSlotMachine(engine.Object);

            //Act
            slotMachine.EnterDeposit(new Money(deposit));
            slotMachine.StakeMoney(new Money(stake));
            slotMachine.Play();

            //Assert
            slotMachine.Balance.Amount.Should().BeLessThan(deposit).And.BeGreaterThan(deposit - stake);
        }