结构型/外观模式/CommonSample.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace DesignModeConsole.结构型.外观模式;
/// <summary>
/// 普通的写法
/// </summary>
public class CommonSample
{
public void Main()
{
const int amout = 1000;
var customer = new Customer("张三");
var bank = new Bank();
var loan = new Loan();
var credit = new Credit();
var eligible = true;
if (!bank.HasSufficientSavings(customer, amout))
{
eligible = false;
}
else if (!loan.HasNoBadLoans(customer))
{
eligible = false;
}
else if (!credit.HasGoodCredit(customer))
{
eligible = false;
}
var result = eligible ? "满足" : "不满足";
Console.WriteLine($"顾客{customer.Name} {result}贷款要求");
}
}
/// <summary>
/// 顾客类
/// </summary>
public class Customer
{
public Customer(string name)
{
Name = name;
}
public string Name { get; set; }
}
/// <summary>
/// 银行子系统
/// </summary>
public class Bank
{
public bool HasSufficientSavings(Customer customer, int amount)
{
Console.WriteLine("检查顾客" + customer.Name + "余额");
return true;
}
}
后面还有 24 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。