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的更多相关文章

  1. MyBank(自助银行)系统

    光阴似箭,岁月如梭. 从开始学Java到现在学C#已快四个月了,我们学的东西越来越多了.但是虽说学到现在,都不知道有什么用?没地方表现啊. 那么今天我就来给大家说说说这些东西的用处吧. 就拿MyBan ...

  2. 迷你MyBank

    该迷你MyBank,存贮是用对象数组来存贮的,所以比较简单,容易理解,适合新手.. 一.创建chengyuan类,在其中声明所需的成员变量: public class chengyuan { //该类 ...

  3. MyBank后感

    MyBank系统主要的构成部分有:银行账户的初始化,开户,存款,取款,转账,查询余额,修改密码这些操作. =============================================== ...

  4. 使用属性升级MyBank

    一.访问修饰符  private   :使用private访问修饰符修饰的属性或者方法只能在本类中使用 public    :可以在任何类中访问到 二.this 关键字:代表当前类,this.属性:代 ...

  5. C#语言————第三章 使用属性升级MyBank

    ********常见的访问修饰符*********: public :公共的,可以在其他类中访问 private:私有的,只有在本类里可以使用,其他的类无权访问 类的默认访问修饰符 internal( ...

  6. 保护ASP.NET 应用免受 CSRF 攻击

    CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSRF/ ...

  7. Mybatis批量操作

    首先,mysql需要数据库连接配置&allowMultiQueries=true jdbc:mysql://127.0.0.1:3306/mybank?useUnicode=true& ...

  8. C#语言和数据库基础

    第一章 第一个C#程序 Vs2012密钥 RBCXF-CVBGR-382MK-DFHJ4-C69G8 01..net和C#的区别 大概在2000年,微软推出了一种革命性的产品--.NET(战略) 目标 ...

  9. [转]浅谈CSRF攻击方式

    在CSDN中看到对CSRF攻击的原理及防护文章,讲解浅显易懂,特转之: 来源:http://blog.csdn.net/fationyyk/article/details/50833620 一.CSR ...

随机推荐

  1. 第三百五十三天 how can I 坚持

    今天买了床被子,凑合盖吧,也不是多好. 下午去了趟华北电力大学,和刘路聊了聊,还是话太多了..不好. 还有买了桶油和大米.. 洗澡,睡觉,一天过得好快.

  2. Linux下Python获取IP地址

    <lnmp一键安装包>中需要获取ip地址,有2种情况:如果服务器只有私网地址没有公网地址,这个时候获取的IP(即私网地址)不能用来判断服务器的位置,于是取其网关地址用来判断服务器在国内还是 ...

  3. Spark RDD概念学习系列之RDD的checkpoint(九)

     RDD的检查点 首先,要清楚.为什么spark要引入检查点机制?引入RDD的检查点?  答:如果缓存丢失了,则需要重新计算.如果计算特别复杂或者计算耗时特别多,那么缓存丢失对于整个Job的影响是不容 ...

  4. (转载)Java里快如闪电的线程间通讯

    转自(http://www.infoq.com/cn/articles/High-Performance-Java-Inter-Thread-Communications) 这个故事源自一个很简单的想 ...

  5. LabVIEW数据记录和存储—XML文件

    XML(eXtensible Markup Language)是一种目前广泛使用的数据传输和存储的格式,其本质上是一种文本文件,可以使用任何一个文本编辑工具打开和修改.类似于HTML,XML被设计为具 ...

  6. sql表设计器的几个默认值

    sql表设计器的几个默认值: 空字符串‘’(注意是单引号) 当前时间getdate() 逻辑值0或1 汉字或英文字符串需在前面加大写N,并用单引号引起如: N'已发货'

  7. ADT下开发环境的配置--个人配置啦 Eclipse Color Themes

    一. Eclipse Color Themes的安装 首先 这个ADT没有Marketplace Client 需要装一个, 节选自: http://blog.csdn.net/liu37226700 ...

  8. 一个简单的Java程序例子以及其几种注释

    在说道主题前,先来啰嗦两句,o()︿︶)o 唉,不说两句心里就有个疙瘩,也许这就是所谓的强迫症吧,好了说说我想啰嗦的,其实也就是这样子的,关于Java开发工具箱的下载以及环境的配置.Java开发工具箱 ...

  9. perl学习笔记(4)——动态加载

    在写perl的时候,如果要应用到各种平台的话,比如linux 和windows,会遇到各种问题,有时就是要根据系统类型来加载各种库,之前写的就是这样的, if($^O eq 'linux'){ use ...

  10. OSX apache vhost 配置多站点时403错误解决方法

    到 /etc/apache2/httpd.conf 这个文件修改下面的路径就好了 DocumentRoot "/Users/wujinhang/workspace/"<Dir ...