Ejemplo n.º 1
0
 private void MakeDrink()
 {
     _selectedDrink.LogDrinkMaking(LogText);
     LogText.Add($"Finished making {_selectedDrink.Name}");
     LogText.Add("------------------");
     _selectedDrink = null;
 }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
 private void DrinkPaid()
 {
     _drinkFactory.SelectedDrink.LogDrinkMaking(LogText);
     LogText.Add($"Finished making {_drinkFactory.SelectedDrink.GetName()}");
     LogText.Add("------------------");
     _drinkFactory.SelectedDrink = null;
 }
Ejemplo n.º 4
0
 private void UpdateInfoAfterNewDrink()
 {
     RemainingPriceToPay = _drinkFactory.SelectedDrink.GetPrice();
     LogText.Add($"Selected {_drinkFactory.SelectedDrink.GetName()}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
     RaisePropertyChanged(() => SelectedDrinkName);
     RaisePropertyChanged(() => SelectedDrinkPrice);
 }
 private void CheckRemainingPriceToPay()
 {
     if (RemainingPriceToPay == 0)
     {
         _selectedDrink.LogDrinkMaking(LogText);
         LogText.Add("------------------");
         _selectedDrink = null;
     }
 }
 //Helper method
 private bool CheckSelectedDrink(string drinkName)
 {
     if (_selectedDrink == null)
     {
         LogText.Add($"Could not make {drinkName}, recipe not found.");
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
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)}");
 }
Ejemplo n.º 8
0
 private void FinishMakingDrink()
 {
     if (_selectedDrink != null)
     {
         _selectedDrink.LogText(LogText);
         LogText.Add($"Finished making {_selectedDrink.Name}");
         LogText.Add("------------------");
         _selectedDrink = null;
     }
 }
Ejemplo n.º 9
0
        private void PayDrink(string PayMethod, double insertedMoney = 0)
        {
            RemainingPriceToPay = _paymentFactory.Pay(PayMethod).remainingPriceToPay(this._selectedDrink, this._selectedPaymentCardUsername, this._remainingPriceToPay, LogText, insertedMoney);

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

            this.RaisePropertyChanged(() => this.PaymentCardRemainingAmount);
        }
Ejemplo n.º 10
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();
            }
        }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 14
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;
            }
        }
Ejemplo n.º 15
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     _logWindow.Show();
     LogText.Add("Button1 Clicked");
 }
Ejemplo n.º 16
0
 private void SendDrinkUpdate()
 {
     RemainingPriceToPay = _selectedDrink.Price;
     LogText.Add($"Selected {_selectedDrink.Name}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}");
 }