bank.cs

来自「实现ATM的主要功能:开户」· CS 代码 · 共 55 行

CS
55
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace ATM
{
    class Bank
    {
        protected const int MaxAccountNum = 2048;
        protected string name;
        protected int usedAccountNum;
        protected Account[] accounts;

        public string Name
        {
            get
            {
                return name;
            }
        }

        public Bank(string name)
        {
            this.name = name;
            this.usedAccountNum = 0;
            accounts = new Account[MaxAccountNum];
        }
        public bool LoginAccount(string name, string password, out Account account)
        {
            account = null;
            for (int i = 0; i < usedAccountNum; ++i)
            {
                if (accounts[i].Login(name, password))
                {
                    account = accounts[i];
                    return true;
                }
            }
            return false;
        }
        public bool OpenAccount(string name, string password, out Account account)
        {
            account = null;
            for (int i = 0; i < usedAccountNum; ++i)
            {
                if (accounts[i].Name == name)
                    return false;
            }
            account = new Account(name, password);
            accounts[usedAccountNum++] = account;
            return true;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?