asp.net程序ATM



这是ASP.NET的文档using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ATM { class Bank { private List<Account> accounts; public List<Account> Accounts { get { return accounts; } set { accounts = value; } } private int currentAccountNumber; public int CurrentAccountNumber { get { return currentAccountNumber; } set { currentAccountNumber = value; } } public Bank() { accounts = new List<Account>(); } public Account OpenAccount(string password, string confirmationPassword, string name, string personId, string email, int typeOfAccount) { Account newAccount; if (!password.Equals(confirmationPassword)) { throw new InvalidOperationException("两次密码输入的不一致!"); } switch (typeOfAccount) { case 1: newAccount = new SavingAccount(password, name, personId, email); break; case 2: newAccount = new CreditAccount(password, name, personId, email); break; default:throw new ArgumentOutOfRangeException("账户类型是1到2之间的整数"); } accounts.Add(newAccount); return newAccount; } private Account GetAccountByID(long id) { foreach (Account account in accounts) { if(account.ID==id) { return account; } } return null; } public Account SignIn(long id, string password) { foreach (Account account in accounts) { if (account.ID == id && account.Password.Equals(password)) { return account; } } throw new InvalidOperationException("用户名或者密码不正确,请重试!"); } public Account Deposit(long id, double sum) { Account account = GetAccountByID(id); if (account != null) { account.Deposit(sum); return account; } throw new InvalidOperationException("非法账号!"); } public Account Withdraw(long id, double sum) { Account account = GetAccountByID(id); if (account != null) { account.Withdraw(sum); return account; } throw new InvalidOperationException("非法账号!"); } public Account SetCeiling(long id, double newCeiling) { Account account = GetAccountByID(id); try { (account as CreditAccount).Ceiling = newCeiling; return account; } catch (Exception ex) { throw new InvalidOperationException("此账户不是信用账户!"); } throw new InvalidOperationException("非法账号!"); } public double GetTotalBalance() { double totalBalance = 0; foreach (Account account in accounts) { totalBalance += account.Balance; } return totalBalance; } public double GetTotalCeiling() { double totalCeiling = 0; foreach (Account account in accounts) { if (account is CreditAccount) { totalCeiling += (account as CreditAccount).Ceiling; } } return totalCeiling; } } }



















































- 1

- 满芒2014-01-02还不错,值得学习

- 粉丝: 1
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 2014版CAD操作教程.doc
- (源码)基于Arduino的Orbita50 Swiss Edition音乐硬件固件项目.zip
- 基于Matlab的ARIMA模型:自回归差分移动平均模型(p,d,q)的步骤与实现
- 网站制作推广策划书方案模板.docx
- 移动web技术.ppt
- 建设工程项目管理习题.doc
- 某年度中国软件产业高级管理人员培训班.pptx
- 网络营销策划的概念.doc
- 2023年广西三类人员安全继续教育网络考试试题及参考答案.doc
- 电子商务行业人力资源管理方案设计.doc
- 模块十设计网络营销渠道PPT课件.ppt
- 基于MATLAB的锅炉水温与流量串级控制系统的设计.doc
- 工程项目管理风险研究.doc
- 实验室项目管理知识计划书.doc
- 岩土工程CAD深基础支护.ppt
- MATLAB实现光子晶体滤波器:缺陷层折射率对中心波长偏移影响研究 实战版


