资源简介
银行系统:
1)程序中使用事件及委托。参照视频中提到的“六步法”,在ATM类中实现一个事件BigMoneyFetched (一大笔钱被取走了),即ATM机在操作时如果用户取款数大于10000,则可以激活这个事件。事件参数也是一个对象(可以定义类BigMoneyArgs),含有账号及当时取款数。在程序中(如Main中)注册这个事件,使之能在界面中显示出告警信息(相当于银行的监控功能)。
2)程序中使用自定义异常。比如,定义一个异常类BadCashException,表示有坏的钞票。在程序中适当的地方(如取款函数)中,抛出(throw)(自定义的异常类(如random的Next(3)小于1,表示有三个之一的概率时就抛出),在ATM调用这个函数时进行捕获(catch)。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System;
using System.Windows.Forms;
namespace ATM
{
public partial class Form1 : Form
{
public static Account a = new Account();
public static CreditAccount ca = new CreditAccount();
public Form1()
{
InitializeComponent();
}
public static string name pass;
private string login_input_ID login_input_pass;
private void Form1_Load(object sender EventArgs e)
{
}
private void button3_Click(object sender EventArgs e)
{
if (!String.IsNullOrEmpty(login_input_ID) && !String.IsNullOrEmpty(login_input_pass))
{
Form3 f3 = new Form3();
if (login_input_ID == a[0] && login_input_pass == a.password)
f3.Show();
else
MessageBox.Show(“wrong ID or password.“);
}
else
{ //use custom Exception Error number 0
try
{
Account.emptyInput(login_input_ID);
Account.emptyInput(login_input_pass);
}
catch (EmptyException ex)
{
MessageBox.Show(ex.Message + ex.getId());
}
}
}
private void button1_Click(object sender EventArgs e)
{
Form2 f2 = new Form2();
name = pass = null;
f2.Show();
}
private void textBox1_TextChanged(object sender EventArgs e)
{
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
login_input_ID = this.textBox1.Text;
}
private void textBox2_TextChanged(object sender EventArgs e)
{
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
login_input_pass = this.textBox2.Text;
}
}
public class BigMoneyArgs : EventArgs
{
public int ID;
public int amount_fetch;
}
public delegate void BigMoneyHandler(object sender BigMoneyArgs e);
//defining Exception classes
class SurpassException : ApplicationException
{
private int idnumber;
public SurpassException(String message int id) : base(message)
{
this.idnumber = id;
}
public int getId()
{
return idnumber;
}
}
class EmptyException : ApplicationException
{
private int idnumber;
public EmptyException(String message int id) : base(message)
{
this.idnumber = id;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-04-22 15:50 ATM\
目录 0 2020-04-22 15:50 ATM\.vs\
目录 0 2020-04-22 15:50 ATM\.vs\ATM\
目录 0 2020-04-22 15:50 ATM\.vs\ATM\v16\
文件 53248 2020-03-28 12:53 ATM\.vs\ATM\v16\.suo
目录 0 2020-04-22 15:50 ATM\.vs\ATM\v16\Server\
目录 0 2020-04-22 15:50 ATM\.vs\ATM\v16\Server\sqlite3\
文件 0 2020-03-21 14:07 ATM\.vs\ATM\v16\Server\sqlite3\db.lock
文件 614400 2020-03-28 12:53 ATM\.vs\ATM\v16\Server\sqlite3\storage.ide
目录 0 2020-04-22 15:50 ATM\ATM\
文件 4202 2020-03-28 12:44 ATM\ATM\ATM.csproj
文件 189 2020-03-21 14:07 ATM\ATM\App.config
文件 4827 2020-03-28 12:30 ATM\ATM\Form1.Designer.cs
文件 12809 2020-03-28 12:47 ATM\ATM\Form1.cs
文件 5817 2020-03-28 12:30 ATM\ATM\Form1.resx
文件 4205 2020-03-28 12:45 ATM\ATM\Form2.Designer.cs
文件 1443 2020-03-28 12:45 ATM\ATM\Form2.cs
文件 5817 2020-03-28 12:45 ATM\ATM\Form2.resx
文件 10582 2020-03-28 12:53 ATM\ATM\Form3.Designer.cs
文件 2320 2020-03-28 12:53 ATM\ATM\Form3.cs
文件 5817 2020-03-28 12:53 ATM\ATM\Form3.resx
文件 515 2020-03-21 14:07 ATM\ATM\Program.cs
目录 0 2020-04-22 15:50 ATM\ATM\Properties\
文件 1298 2020-03-21 14:07 ATM\ATM\Properties\AssemblyInfo.cs
文件 2819 2020-03-21 14:07 ATM\ATM\Properties\Resources.Designer.cs
文件 5612 2020-03-21 14:07 ATM\ATM\Properties\Resources.resx
文件 1090 2020-03-21 14:07 ATM\ATM\Properties\Settings.Designer.cs
文件 249 2020-03-21 14:07 ATM\ATM\Properties\Settings.settings
目录 0 2020-04-22 15:50 ATM\ATM\bin\
目录 0 2020-04-22 15:50 ATM\ATM\bin\Debug\
文件 21504 2020-03-28 12:49 ATM\ATM\bin\Debug\ATM.exe
............此处省略18个文件信息
相关资源
- 模拟ATM柜员机系统--连接数据库
- MCGS与单片机通信
- ATM自动取款机系统的分析与设计
- atmega16硬件产生方波的程序
- atmega64bootload
- 基于MC68HC908RF2的汽车胎压监测系统的
- ATmega16A DataSheet
- THERMAL ANNEALING TREATMENT TO ACHIEVE SWITCHA
- 生物压力识别技术在银行安全中的应
- 自制AVR ATmega16 JTAG2008
- 基于ATmega128和CH374的USB接口设计
- 账户类ATM三个版本
- Anti-CD3 antibody treatment ameliorates transf
- THE RAS/PI3K PATHWAY IS INVOLVED IN THE IMPAIR
- Finite-time blowup for the 3-D primitive equat
- AMT64内存条检测卡DIY制作
- 两轮平衡车源程序,方能仪器,自平
- 载ATM反义寡核苷酸纳米粒对小鼠SCCⅦ
- 最新最全的Atmel元件库
- 基于labview的多种ATM机设计
- Atmega1280芯片资料
- ATmega16(L) 中文数据手册.pdf
- ATM机数据流图及原型图的绘制
- ATMEL AT91SAM7S64的RS485通讯程序源码
- ATMEL USB ISP
- atmel的电容触摸按键软件库使用说明
- ATmega128 开发板PCB
- atmega328p心型流水灯
- ATmega640-1280-1281-2560 数据手册,2560-1
- 实验一 ATM 自动柜员机系统数据流图与
评论
共有 条评论