Пример #1
0
        public Coordinate TakeTurn()
        {
            while (true)
            {
                _readerWriter.Write(Symbol + " Enter a coord x,y: ");
                var userSpecifiedCoord = _readerWriter.ReadLine();
                var coordArray         = userSpecifiedCoord.Split(",");

                if (coordArray.Length != 2)
                {
                    _readerWriter.Write("Invalid input. Please try again.");
                    continue;
                }

                var ifXIsNumber = int.TryParse(coordArray[0], out var xValue);
                var ifYIsNumber = int.TryParse(coordArray[1], out var yValue);

                if (ifXIsNumber && ifYIsNumber)
                {
                    return new Coordinate
                           {
                               X = xValue,
                               Y = yValue
                           }
                }
                ;
            }
        }
    }
Пример #2
0
        internal void UpdateFromIntermediate(Action <IIntermediateUpdater <TObject, TKey> > updateAction, Action <Exception> errorHandler = null)
        {
            if (updateAction == null)
            {
                throw new ArgumentNullException(nameof(updateAction));
            }

            _readerWriter.Write(updateAction)
            .Then(InvokeNext, errorHandler);
        }
Пример #3
0
        internal void UpdateFromIntermediate(Action <IIntermediateUpdater <TObject, TKey> > updateAction)
        {
            if (updateAction == null)
            {
                throw new ArgumentNullException("updateAction");
            }

            _readerWriter.Write(updateAction)
            .Then(InvokeNext, _changes.OnError);
        }
        public string Start()
        {
            _console.Write("Enter Product with Unit Price \n Ex : Product1 UnitPrice \n keep Blank to end");

            string[] inputs = _console.ReadTillBreak();

            List <Product> products = FetchProducts(inputs);

            _console.Write("Enter Rules  \n Ex : 3 of A's for 130 OR C & D for 30 \n keep Blank to end");
            inputs = _console.ReadTillBreak();

            List <IRule> rules = FetchRules(products, inputs);

            products = ProductQuantitySet(products);

            CalculateProductPrices(products);
            ApplyPromotionToProducts(rules);

            return(CalculateTotal(products));
        }
Пример #5
0
        private void DoNextTurn()
        {
            var valid = false;

            while (!valid)
            {
                _userCoord = CurrentPlayer.TakeTurn();
                valid      = _coordinateValidator.IsValid(_board, _userCoord);
                _readerWriter.Write("Please enter valid coordinate (x,y)");
            }

            _board.UpdateSquare(_userCoord, CurrentPlayer.Symbol);
            ChangeState();
        }
Пример #6
0
        public ObservableCache(IObservable <IChangeSet <TObject, TKey> > source)
        {
            _readerWriter = new ReaderWriter <TObject, TKey>();

            var loader = source
                         .FinallySafe(_changes.OnCompleted)
                         .Subscribe(changes => _readerWriter.Write(changes)
                                    .Then(InvokeNext, _changes.OnError)
                                    );

            _disposer = Disposable.Create(() =>
            {
                loader.Dispose();
                _changes.OnCompleted();
                if (_countChanged.IsValueCreated)
                {
                    _countChanged.Value.OnCompleted();
                }
            });
        }
Пример #7
0
 public void Save()
 {
     _rw.Write(Machines, "data");
 }
Пример #8
0
 public void Write(IObjectId x, IObjectValue v)
 {
     readerWriter.Write(x, v);
 }