Beispiel #1
0
        private static void AddExpenseToVatNumber(List <VatNumber> vats)
        {
            VatNumber selected = SelectVat(vats);

            if (selected != null)
            {
                selected.AddExpense();
            }
            else
            {
                Console.WriteLine("The entered VAT number does not exist!");
            }
        }
Beispiel #2
0
        private static void CalculateTotalsOfVatNumber(List <VatNumber> vats)
        {
            VatNumber selected = SelectVat(vats);

            if (selected != null)
            {
                selected.CalculateAndPrint();
            }
            else
            {
                Console.WriteLine("The entered VAT number does not exist!");
            }

            // per essere "a oggetti" al 100% dovrei eliminare tutti branch, if/else, switch, ecc.
            // però rischio di scrivere codice più oscuro e più difficile da gestire.
            //Dictionary<bool, Action> dict = new Dictionary<bool, Action>
            //{
            //    { true, () => selected.CalculateAndPrint() },
            //    { false, () => Console.WriteLine("The entered VAT number does not exist!") },
            //};
            //dict[selected != null]();
        }