📄 account.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace ATM
{
class Account
{
protected string name;
protected string password;
protected decimal balance;
public decimal Balance
{
get
{
return balance;
}
}
public string Name
{
get
{
return name;
}
}
public Account(string name, string password)
{
this.balance = 0;
this.name = name;
this.password = password;
}
public bool Deposit(decimal amount)
{
if (amount <= 0)
return false;
balance += amount;
return true;
}
public bool Deposit(double amount)
{
return Deposit((decimal)amount);
}
public bool Deposit(int amount)
{
return Deposit((decimal)amount);
}
public bool Deposit(decimal amount, out decimal balance)
{
bool succeed = Deposit(amount);
balance = this.balance;
return succeed;
}
public bool Withdraw(decimal amount)
{
if (amount > balance || amount <= 0)
return false;
balance -= amount;
return true;
}
public bool Withdraw(double amount)
{
return Withdraw((decimal)amount);
}
public bool Withdraw(int amount)
{
return Withdraw((decimal)amount);
}
public bool Withdraw(decimal amount, out decimal balance)
{
bool succeed = Withdraw(amount);
balance = this.balance;
return succeed;
}
public bool ChangePassword(string oldPassword, string newPassword)
{
if (oldPassword != password)
return false;
password = newPassword;
return true;
}
public bool Login(string name, string password)
{
return (this.name == name && this.password == password);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -