예제 #1
0
 private void UpdateInfoAfterNewDrink()
 {
     RemainingPriceToPay = _drinkFactory.SelectedDrink.GetPrice();
     LogText.Add($"Selected {_drinkFactory.SelectedDrink.GetName()}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
     RaisePropertyChanged(() => SelectedDrinkName);
     RaisePropertyChanged(() => SelectedDrinkPrice);
 }
예제 #2
0
 private void SendUpdate()
 {
     //ensure that it does not need to look at the sugar price and such.
     RemainingPriceToPay = _selectedDrink.Price;
     RaisePropertyChanged(() => RemainingPriceToPay);
     RaisePropertyChanged(() => SelectedDrinkName);
     RaisePropertyChanged(() => SelectedDrinkPrice);
     LogText.Add($"Selected {_selectedDrink.Name}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
 }
예제 #3
0
        public void Pay(double inserted)
        {
            if (User.Balance >= RemainingPriceToPay)
            {
                User.Balance       -= inserted;
                RemainingPriceToPay = 0;
                LogText.Add($"Inserted {inserted.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
            }
            else
            {
                double moneyLeft = User.Balance;
                User.Balance = 0;

                RemainingPriceToPay -= moneyLeft;
                LogText.Add($"Inserted {moneyLeft.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
            }

            Notify(this);
        }
예제 #4
0
 private void SendDrinkUpdate()
 {
     RemainingPriceToPay = _selectedDrink.Price;
     LogText.Add($"Selected {_selectedDrink.Name}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
 }
예제 #5
0
        private void PayDrink(bool payWithCard, double insertedMoney = 0)
        {
            if (_selectedDrink != null && payWithCard)
            {
                insertedMoney = _cashOnCards[SelectedPaymentCardUsername];
                if (RemainingPriceToPay <= insertedMoney)
                {
                    _cashOnCards[SelectedPaymentCardUsername] = insertedMoney - RemainingPriceToPay;
                    RemainingPriceToPay = 0;
                }
                else // Pay what you can, fill up with coins later.
                {
                    _cashOnCards[SelectedPaymentCardUsername] = 0;

                    RemainingPriceToPay -= insertedMoney;
                }
                LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
                RaisePropertyChanged(() => PaymentCardRemainingAmount);
            }
            else if (_selectedDrink != null && !payWithCard)
            {
                RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - insertedMoney, 2), 0);
                LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
            }

            if (_selectedDrink != null && RemainingPriceToPay == 0)
            {
                _selectedDrink.LogDrinkMaking(LogText);
                LogText.Add("------------------");
                _selectedDrink = null;
            }
        }
 //  return true if fully paid
 public bool payByCoin(ObservableCollection <string> log, double insertedMoney)
 {
     RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - insertedMoney, 2), 0);
     log.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
     return(RemainingPriceToPay == 0);
 }
        // return true if fully paid
        public bool payByCard(ObservableCollection <string> log)
        {
            double insertedMoney = _cashOnCards[SelectedPaymentCardUsername];

            if (RemainingPriceToPay <= insertedMoney)
            {
                _cashOnCards[SelectedPaymentCardUsername] = insertedMoney - RemainingPriceToPay;
                RemainingPriceToPay = 0;
            }
            else // Pay what you can, fill up with coins later
            {
                _cashOnCards[SelectedPaymentCardUsername] = 0;

                RemainingPriceToPay -= insertedMoney;
            }
            log.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
            return(RemainingPriceToPay == 0);
        }
예제 #8
0
        private void PayDrink(bool payWithCard, double insertedMoney = 0)
        {
            if (_selectedDrink != null && payWithCard)
            {
                card.Username       = SelectedPaymentCardUsername;
                insertedMoney       = card.CashOncards[SelectedPaymentCardUsername];
                RemainingPriceToPay = card.PayDrink(RemainingPriceToPay);
                RaisePropertyChanged(() => PaymentCardRemainingAmount);
            }
            else if (_selectedDrink != null && !payWithCard)
            {
                RemainingPriceToPay = paymentFactory.CreatePayment("Coin", insertedMoney, null).PayDrink(RemainingPriceToPay);
            }
            LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");

            if (_selectedDrink != null && RemainingPriceToPay == 0)
            {
                _selectedDrink.LogDrinkMaking(LogText);
                LogText.Add("------------------");
                _selectedDrink = null;
            }
        }
예제 #9
0
        private void HandlePayment(object sender, PaymentSystem.PriceChanged e)
        {
            RemainingPriceToPay = e.RemainingPrice;
            _userRepository     = e.UserRepository;
            _cashOnCards        = _userRepository.Cards;

            RaisePropertyChanged(() => PaymentCardRemainingAmount);

            LogText.Add($"Inserted {e.InsertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
            if (_selectedDrink != null && RemainingPriceToPay <= 0)
            {
                MakeDrink();
            }
        }
예제 #10
0
        private void PrintSelectionAndPrice()
        {
            bool hasSugar = false;
            bool hasMilk  = false;

            if (SugarAmount != Amount.None && _selectedDrink.CompatibleToppings.Contains("Sugar"))
            {
                hasSugar = true;
            }
            if (MilkAmount != Amount.None && !_selectedDrink.CompatibleToppings.Contains("Milk"))
            {
                hasMilk = true;
            }
            RemainingPriceToPay = _selectedDrink.GetPrice();
            LogText.Add($"Selected {_selectedDrink.Name}{(hasSugar ? hasMilk ? " with sugar and milk" : " with sugar" : hasMilk ? " with Milk" : "")}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
            RaisePropertyChanged(() => RemainingPriceToPay);
            RaisePropertyChanged(() => SelectedDrinkName);
            RaisePropertyChanged(() => SelectedDrinkPrice);
        }
        public void Pay(double inserted)
        {
            RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - inserted, 2), 0);
            LogText.Add($"Inserted {inserted.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");

            Notify(this);
        }
예제 #12
0
        public void PayDrinkByCoins(double insertedMoney)
        {
            _payFactory.getPayMethod("Coin").Pay(insertedMoney, RemainingPriceToPay);
            RemainingPriceToPay = _payFactory.getPayMethod("Coin").getRemainingPriceToPay();

            LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");

            if (_selectedDrink != null && RemainingPriceToPay == 0)
            {
                _selectedDrink.LogDrinkMaking(LogText);
                LogText.Add("------------------");
                _selectedDrink = null;
            }
        }
예제 #13
0
        public void PayDrinkByCard()
        {
            if (_selectedDrink != null)
            {
                double insertedMoney = _cashOnCards[SelectedPaymentCardUsername];

                _payFactory.getPayMethod("Card").Pay(_cashOnCards[SelectedPaymentCardUsername], RemainingPriceToPay);
                _cashOnCards[SelectedPaymentCardUsername] = _payFactory.getPayMethod("Card").getNewAmount();
                RemainingPriceToPay = _payFactory.getPayMethod("Card").getRemainingPriceToPay();

                LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}.");
                RaisePropertyChanged(() => PaymentCardRemainingAmount);
            }

            if (_selectedDrink != null && RemainingPriceToPay == 0)
            {
                _selectedDrink.LogDrinkMaking(LogText);
                LogText.Add("------------------");
                _selectedDrink = null;
            }
        }