Exemplo n.º 1
0
 /// <summary>
 ///     查余额
 /// </summary>
 public void QueryBalance()
 {
     if (_bankSubsystem.CheckBalance(_account) > 0)
     {
         AccountSubsystem.Display(_account);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     转账
 /// </summary>
 /// <param name="targetNo"></param>
 /// <param name="money"></param>
 public void TransferMoney(string targetNo, int money)
 {
     if (_bankSubsystem.TransferMoney(_account, targetNo, money))
     {
         Console.WriteLine("转账成功!");
         AccountSubsystem.Display(_account);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///     存款
 /// </summary>
 /// <param name="money"></param>
 public void DepositCash(int money)
 {
     if (_bankSubsystem.DepositMoney(_account, money))
     {
         Console.WriteLine("存款成功!");
         AccountSubsystem.Display(_account);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///     取款
 /// </summary>
 /// <param name="money"></param>
 public void WithdrewCash(int money)
 {
     if (_bankSubsystem.WithdrewMoney(_account, money))
     {
         Console.WriteLine("取款成功!");
         AccountSubsystem.Display(_account);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///     转账
        /// </summary>
        /// <param name="account">转出账户</param>
        /// <param name="targetNo">目标账户</param>
        /// <param name="money">转多少钱</param>
        /// <returns></returns>
        public bool TransferMoney(BankAccount account, string targetNo, int money)
        {
            var targetAccount = AccountSubsystem.GetAccount(targetNo);

            if (targetAccount == null)
            {
                throw new Exception("目标账户不存在!");
            }

            if (account.TotalMoney < money)
            {
                throw new Exception("余额不足!");
            }

            account.TotalMoney       -= money;
            targetAccount.TotalMoney += money;

            return(true);
        }
Exemplo n.º 6
0
 public void Login(string no, string pwd)
 {
     _account = AccountSubsystem.Login(no, pwd);
 }