Java教程

银行还款系统

本文主要是介绍银行还款系统,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 clone地址:https://github.com/mostimacc/ConsoleApp-.git

using System;
class Saving_card
{
private int money;
public string customer;
public int Money
{
get
{
return money;
}
set
{
money = value;
}
}
}
class Credit_Card : Saving_card
{
private int time;
Saving_card card;
private int maxpayment = 10000;
public Credit_Card(string u, int t, int m, Saving_card c)
{
customer = u; time = t; Money = m; card = c;
}
public int Time
{

get
{
return time;
}
set
{
time = value;
}
}
public void paymoney()
{
if (Money < maxpayment)
{
Console.WriteLine("您本月消费:{0}", Money);

Console.WriteLine("用户{0}:信用卡待还:{1},储蓄卡余额:{2}", customer, Money, card.Money);
if (card.Money < Money)
{
Money -= card.Money;
card.Money = 0;
Console.WriteLine("已到还款日期,您的储蓄卡余额不足,信用卡待还:{0},储蓄卡余额为0", Money - card.Money);
}
else
{
card.Money -= Money;
Money = 0;
Console.WriteLine("已到还款日期,还完欠款后,信用卡待还为0,储蓄卡余额:{0}", card.Money - Money);
}
}
else
Console.WriteLine("您没有那么多的额度");
}
public void notime()
{
Console.WriteLine("未到还款日期,储蓄卡余额:{0},信用卡待还:{1}", Money, card.Money);
}

}

class Paydelegate
{
public delegate void paydelegate();
public event paydelegate payevent;
public void Notify()
{
if (payevent != null)
{

payevent();
}
}
}
class program
{
static void Main(string[] args)
{
int paytime = 15;
Saving_card sc = new Saving_card();
sc.Money = 1000;
Credit_Card C1 = new Credit_Card("张三",15, 100, sc);
Paydelegate pay = new Paydelegate();
if (paytime == C1.Time)
{
pay.payevent += new Paydelegate.paydelegate(C1.paymoney);
}
else
pay.payevent += new Paydelegate.paydelegate(C1.notime);
pay.Notify();
}
}

这篇关于银行还款系统的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!