public class Account { public static string accountNumber; public static string pin; public static double availableBalance; public static double totalBalance; public Account() { accountNumber = "2202010744"; pin = "123456"; availableBalance = 5000.00; totalBalance = 5000.00; } public static string Pin { get { return pin; } set { pin = value; } } public static string AccountNumber { get { return accountNumber; } } public static double AvailableBalance { get { return availableBalance; } set { availableBalance = value; } } public static double TotalBalance { get { return totalBalance; } set { totalBalance = value; } } //public bool ValidatePin(int userPIN) //{ // return (userPIN == pin); //} public static void Credit(double amount) { totalBalance += amount; } public static void Debit(double amount) { availableBalance -= amount; totalBalance -= amount; } } static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LoginPage f2 = new LoginPage(); Application.Run(f2); } },给这段代码加上详细的注释。
时间: 2024-04-23 10:21:49 浏览: 63
注释如下:
```C#
public class Account
{
//账户相关信息
public static string accountNumber; //账户号码
public static string pin; //账户密码
public static double availableBalance; //账户可用余额
public static double totalBalance; //账户总余额
//构造函数,初始化账户信息
public Account()
{
accountNumber = "2202010744"; //默认账户号码
pin = "123456"; //默认密码
availableBalance = 5000.00; //默认可用余额
totalBalance = 5000.00; //默认总余额
}
//账户密码属性,可读可写
public static string Pin
{
get { return pin; }
set { pin = value; }
}
//账户号码属性,只读
public static string AccountNumber
{
get { return accountNumber; }
}
//账户可用余额属性,可读可写
public static double AvailableBalance
{
get { return availableBalance; }
set { availableBalance = value; }
}
//账户总余额属性,可读可写
public static double TotalBalance
{
get { return totalBalance; }
set { totalBalance = value; }
}
//账户加钱方法
public static void Credit(double amount)
{
totalBalance += amount;
}
//账户扣钱方法
public static void Debit(double amount)
{
availableBalance -= amount;
totalBalance -= amount;
}
}
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginPage f2 = new LoginPage(); //创建登录页面对象
Application.Run(f2); //运行登录页面
}
}
```
阅读全文