public void Test() { Bank bank = new Bank(); Loan loan = new Loan(); Credit credit = new Credit(); Customer customer = new Customer("Ann McKinsey"); bool eligible = true; if (!bank.HasSufficientSavings(customer, _amount)) { eligible = false; } else if (!loan.HasNoBadLoans(customer)) { eligible = false; } else if (!credit.HasGoodCredit(customer)) { eligible = false; } Console.WriteLine("{0} 用户的贷款申请被 {1} 了...", customer.Name , (eligible ? "通过" : "拒绝")); }
public void Test() { // 外观 Mortgage mortgage = new Mortgage(); Customer customer = new Customer("Ann McKinsey"); bool eligable = mortgage.IsEligible(customer, 125000); Console.WriteLine("{0} 用户的贷款申请被 {1} 了...", customer.Name, (eligable ? "通过" : "拒绝")); }
public bool IsEligible(Customer cust, int amount) { Console.WriteLine("门面类 ==> {0} 申请 {1:C} 贷款!", cust.Name, amount); bool eligible = true; if (!bank.HasSufficientSavings(cust, amount)) { eligible = false; } else if (!loan.HasNoBadLoans(cust)) { eligible = false; } else if (!credit.HasGoodCredit(cust)) { eligible = false; } return eligible; }
public bool HasNoBadLoans(Customer c) { Console.WriteLine("贷款子系统查询{0}有无贷款未还情况......", c.Name); return true; }
public bool HasGoodCredit(Customer c) { Console.WriteLine("信用子系统查询{0}用户是否有不良信用记录......", c.Name); return true; }
public bool HasSufficientSavings(Customer c, int amount) { Console.WriteLine("银行子系统查询{0}用户是否有足够多的存款......", c.Name); return true; }