代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace studentwork
{
class Savings
{
int RemainingSum = 20000;
Credit x; //信用
public Savings(Credit x)
{
this.x = x;
}
public void DeductMoney() //扣款
{
if (x.CheckPayment() == 1)
{
RemainingSum = RemainingSum - x.GetAmountPending();
Console.WriteLine("还款成功,余额为:{0}", RemainingSum);
}
else
{
Console.WriteLine("不需要还款,余额为:{0}", RemainingSum);
}
}
}
class Credit
{
int DueDate = 29;
int AmountPending;
int DateOfRepayment;
public Credit(int RepaymentAmount, int RepaymentDate)
{
this.AmountPending = RepaymentAmount;
this.DateOfRepayment = RepaymentDate;
}
public int GetAmountPending()
{
return AmountPending;
}
public int CheckPayment()
{
if (DueDate == DateOfRepayment)
return 1;
else
return 0;
}
}
class Delegate
{
public delegate void pay();
public event pay payment;
public void Notify()
{
if (payment != null)
{
Console.WriteLine("触发事件:");
payment();
}
}
}
class Program
{
static void Main(string[] args)
{
Delegate objDelegate = new Delegate();
Credit a1 = new Credit(1000, 27);
Credit a2 = new Credit(1000, 29);
Savings b1 = new Savings(a1);
Savings b2 = new Savings(a2);
objDelegate.payment +=
new Delegate.pay(b1.DeductMoney);
objDelegate.payment +=
new Delegate.pay(b2.DeductMoney);
objDelegate.Notify();
Console.ReadLine();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。