Ejemplo n.º 1
0
        public static void FacadeDesignPattern()
        {
            string _approved = "approved";
            string _rejected = "rejected";

            // Facade
            Mortgage mortgage = new Mortgage();

            // Evaluate mortgage eligibility for customer
            Customer customer = new Customer("Ann McKinsey");
            bool     eligible = mortgage.IsEligible(customer, 125000);

            Console.WriteLine($"{ customer.Name} has been" + (eligible ? _approved : _rejected));


            // Wait for user
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            /*Structural Pattern*/
            Facade facade = new Facade();

            facade.methodA();
            facade.methodB();

            /*Real World Code Example*/
            Mortgage mortgage = new Mortgage();
            Customer customer = new Customer("Gowtham");

            Console.WriteLine("\nEnter the Loan amount to check your eligibility:");
            int loanAmount = Convert.ToInt32(Console.ReadLine());

            bool eligible = mortgage.isEligible(customer, loanAmount);

            if (eligible)
            {
                Console.WriteLine("\n {0} application has been " + (eligible ? "Approved":"Rejected"), customer.Name);
            }

            Console.ReadLine();
        }