Mybank
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyBank
{
class Bank
{
Card[] twos = new Card[];
public void fx()
{
//第一张卡
Card t1 = new Card();
t1.kahao = "";
t1.mima = "";
t1.names = "小明";
t1.yumoney = ;
//第二张卡
Card t2 = new Card();
t2.kahao = "";
t2.mima = "";
t2.names = "小词";
t2.yumoney = ; twos[] = t1;
twos[] = t2;
}
public void Show() {
for (int i = ; i < twos.Length; i++)
{
if (twos[i] != null)
{
Console.WriteLine("持卡人:{0}\t余额:{1}", twos[i].names, twos[i].yumoney);
}
}
Console.WriteLine("=====================================================");
} //欢迎界面
public void huanying()
{
bool flag = true;
while (flag)
{
Console.WriteLine("\n欢迎进入\t某某某‘s \t的ATM系统\n");
Console.WriteLine("请选择功能模块,按照以下操作↓");
Console.WriteLine("===============================欢迎使用自动银行服务============================= ");
Console.WriteLine("1:开户\t 2:存款\t 3:取款\t 4:查询余额\t 5:转账\t 6:修改密码\t 7:退出");
Console.WriteLine("================================================================================ ");
string choice = Console.ReadLine();
switch (choice)
{
case "":
//开户
kaihu();
break;
case "":
//存款
MoneyIn();
break;
case "":
//取款
MoneyOut();
break;
case "":
//查询余额
chaxunMoney();
break;
case "":
//转账
TransferMoney();
break;
case "":
//修改密码
ModifyPwd();
break;
case"":
//退出
Console.WriteLine("欢迎使用");
break;
default:
Console.WriteLine("您输入的有误,请从新输入!");
Console.WriteLine("");
break;
}
Console.ReadLine();
} }
//开户
public void kaihu()
{
Console.WriteLine("这里是开户功能");
Console.WriteLine("请输入账号:");
string zh = Console.ReadLine();
foreach (Card item in twos)
{
if (item.kahao.Equals(zh))
{
Console.WriteLine("已有账号,请从新输入:");
zh = Console.ReadLine();
}
Console.WriteLine("请输入密码:");
string kaPwd = Console.ReadLine();
Console.WriteLine("请输入预存款金额:");
double money = double.Parse(Console.ReadLine());
Card two = new Card();
two.kahao = zh;
two.mima = kaPwd;
two.yumoney = money;
for (int i = ; i < twos.Length; i++)
{
if (twos[i] == null)
{
twos[i] = two;
Console.WriteLine("恭喜您,开户成功,您的卡号是{0}", zh);
break;
}
}
break;
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num=char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临"); break;
}
} //存款
public void MoneyIn()
{
Console.WriteLine("欢迎进入存款区");
Console.WriteLine("请输入账号");
string zh2 = Console.ReadLine();
bool flag = false;
foreach (Card item in twos)
{
if (item != null)
{
if (item.kahao.Equals(zh2))
{
flag = true;
Console.WriteLine("请输入存款金额");
double money = double.Parse(Console.ReadLine());
item.yumoney += money;
Console.WriteLine("存款成功,当前余额为:{0}", item.yumoney); break;
}
}
}
if (flag == false)
{
Console.WriteLine("卡号不存在");
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num = char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临!凸^-^凸"); break;
}
}
//取款
public void MoneyOut()
{
Console.WriteLine("请输入账号");
string account = Console.ReadLine();
bool kh = false;
foreach (Card item in twos)
{
if (item != null)
{
if (item.kahao.Equals(account))
{
kh = true;
Console.WriteLine("请输入密码");
string pwd2 = Console.ReadLine();
if (item.mima.Equals(pwd2))
{
Console.WriteLine("请输入取款金额");
double money = double.Parse(Console.ReadLine());
while (money > item.yumoney)
{
Console.WriteLine("余额不足,请重新输入取款金额");
money = double.Parse(Console.ReadLine());
}
item.yumoney -= money;
Console.WriteLine("取款成功");
Console.WriteLine("当前卡内余额{0}", item.yumoney);
break; }
else
{
Console.WriteLine("密码错误");
}
}
}
}
if (kh == false)
{
Console.WriteLine("没有该卡号");
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num=char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临!"); break;
}
}
//查询余额
public void chaxunMoney()
{
bool flag = false;
Console.WriteLine("请输入卡号");
string account = Console.ReadLine();
Console.WriteLine("请输入密码");
string pwd = Console.ReadLine();
foreach (Card item in twos)
{
if (item!=null)
{
if (item.kahao.Equals(account) && item.mima.Equals(pwd))
{
flag=true;
Console.WriteLine("用户名是{0}的账户余额是{1}", item.names, item.yumoney);
break;
}
}
}
if (flag==false)
{
Console.WriteLine("账号有误,请从新输入");
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num=char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临!"); break;
}
} //转账
public void TransferMoney()
{
Console.WriteLine("请输入转出卡卡号");
string zc = Console.ReadLine();
bool fromIsOrNot = false;
bool toIsOrNot = false;
foreach (Card item in twos)
{
if (item!=null&&item.kahao.Equals(zc))
{
fromIsOrNot = true; Console.WriteLine("请输入转出卡卡密码");
string pwdFrom = Console.ReadLine();
if (item.mima.Equals(pwdFrom))
{
Console.WriteLine("请输入转入卡卡号");
string zr = Console.ReadLine();
foreach (Card toItem in twos)
{
if (toItem!=null&&toItem.kahao.Equals(zr))
{
toIsOrNot = true;
Console.WriteLine("请输入转账金额");
double money = double.Parse(Console.ReadLine());
while (money > item.yumoney)
{
Console.WriteLine("转账金额不够,请重新输入");
money = double.Parse(Console.ReadLine());
}
item.yumoney -= money;
toItem.yumoney += money;
Console.WriteLine("转账成功,您的余额为{0}",item.yumoney);
break;
} }
if (toIsOrNot==false)
{
Console.WriteLine("转入卡不存在");
}
break;
}
else
{
Console.WriteLine("转出卡密码错误");
}
}
}
if (fromIsOrNot==false)
{
Console.WriteLine("转出卡不存在!");
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num=char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临"); break;
}
} //修改密码
public string xinmima;
public void ModifyPwd()
{
Console.WriteLine("请输入账号:");
string no = Console.ReadLine(); for (int i = ; i < twos.Length; i++)
{
if (twos[i] != null)
{
if (twos[i].kahao == no)
{
Console.WriteLine("请输入原密码:");
string mima1 = Console.ReadLine();
for (int j = ; j < ; j++)
{
if (twos[i].mima == mima1)
{
Console.WriteLine("请输入新密码:");
xinmima = Console.ReadLine();
Console.WriteLine("请再次输入新密码:");
if (xinmima == Console.ReadLine())
{
twos[i].mima = xinmima;
Console.WriteLine("账户密码修改成功!!");
break;
} }
} break;
}
}
if (twos[i].kahao != no)
{ Console.WriteLine("您输入的账号不存在!");
break; }
}
Console.WriteLine("\n是否返回主页面?(y/n)");
char num=char.Parse(Console.ReadLine());
switch (num)
{
case 'y':
huanying();
break;
case 'n':
Console.WriteLine("欢迎下次光临");
break;
} } }
}
Card
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyBank
{
class Card
{
//卡号
public string kahao;
//密码
public string mima;
//持卡人
public string names;
//余额
public double yumoney;
}
}
Main()
namespace MyBank
{
class Program
{
static void Main(string[] args)
{
Bank bank = new Bank(); bank.fx();//卡信息
bank.Show();//展示卡信息
bank.huanying();//欢迎界面
Console.ReadLine();
}
}
}
Mybank的更多相关文章
- MyBank(自助银行)系统
光阴似箭,岁月如梭. 从开始学Java到现在学C#已快四个月了,我们学的东西越来越多了.但是虽说学到现在,都不知道有什么用?没地方表现啊. 那么今天我就来给大家说说说这些东西的用处吧. 就拿MyBan ...
- 迷你MyBank
该迷你MyBank,存贮是用对象数组来存贮的,所以比较简单,容易理解,适合新手.. 一.创建chengyuan类,在其中声明所需的成员变量: public class chengyuan { //该类 ...
- MyBank后感
MyBank系统主要的构成部分有:银行账户的初始化,开户,存款,取款,转账,查询余额,修改密码这些操作. =============================================== ...
- 使用属性升级MyBank
一.访问修饰符 private :使用private访问修饰符修饰的属性或者方法只能在本类中使用 public :可以在任何类中访问到 二.this 关键字:代表当前类,this.属性:代 ...
- C#语言————第三章 使用属性升级MyBank
********常见的访问修饰符*********: public :公共的,可以在其他类中访问 private:私有的,只有在本类里可以使用,其他的类无权访问 类的默认访问修饰符 internal( ...
- 保护ASP.NET 应用免受 CSRF 攻击
CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSRF/ ...
- Mybatis批量操作
首先,mysql需要数据库连接配置&allowMultiQueries=true jdbc:mysql://127.0.0.1:3306/mybank?useUnicode=true& ...
- C#语言和数据库基础
第一章 第一个C#程序 Vs2012密钥 RBCXF-CVBGR-382MK-DFHJ4-C69G8 01..net和C#的区别 大概在2000年,微软推出了一种革命性的产品--.NET(战略) 目标 ...
- [转]浅谈CSRF攻击方式
在CSDN中看到对CSRF攻击的原理及防护文章,讲解浅显易懂,特转之: 来源:http://blog.csdn.net/fationyyk/article/details/50833620 一.CSR ...
随机推荐
- 在VS2012中实现Ext JS的智能提示
Visual Studio 2012太强大了,居然能自己会去提取Ext JS的类的属性和方法,从而实现只能提示.下面就来介绍一下实现这个功能. 在Visual Studio 2012中随便创建一个We ...
- IE下判断IE版本的语句...[if lte IE 6]……[endif]
<!--[if lte IE 6]> <![endif]--> IE6及其以下版本可见 <!--[if lte IE 7]> <![endif]--> ...
- OC:点语法
IOS中的@property 与 assign copy retain 的区别参考 //@理解为 OC 代码的标记 //如何去创建一个对象 创建对象的两步: // (1)为对象在堆区中开辟空间 Stu ...
- 如何判断js中的数据类型(转)
如何判断js中的数据类型:typeof.instanceof. constructor. prototype方法比较 如何判断js中的类型呢,先举几个例子: var a = "iamstri ...
- jsp中使用动态数据进行mySQL数据库的两种操作方法
使用动态数据进行数据库内容的增删改查操作有两种方法: 在此定义数据库连接为conn 假设有表单进行数据输入并提交到处理页面一种是使用预编译格式: 其格式如下: String name = reques ...
- 获取oracle 表字段,表名,以及主键之类等等的信息
数据库版本号:select * from v$version 数据库名:select * from v$instance 注意: 我在C#项目中查询语句的时候报“ORA-00911: 无效字符” 的错 ...
- cocos2dx 兼容性
报错: Caused by: java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp: findLibrary returned null 因 ...
- pic/at89c2051 programmer
http://dangerousprototypes.com/forum/viewtopic.php?t=170 It looks like the PICKIT2 uses a small boos ...
- java android ExecutorService 线程池解析
ExecutorService: 它也是一个接口,它扩展自Executor接口,Executor接口更像一个抽象的命令模式,仅有一个方法:execute(runnable);Executor接口简单, ...
- LVM管理及扩容(转)
LVM磁盘管理 一、LVM简介... 1 二、 LVM基本术语... 2 三、 安装LVM... 3 四、 创建和管理LVM... 4 2、 创建PV.. 6 3、 创建VG.. 7 4、 创建LV. ...