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. ntpdate server时出错原因及解决

    错误1.Server dropped: Strata too high 在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronizati ...

  2. JVM系列一:JVM内存组成及分配

    java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时 ...

  3. 【132】iPad使用相关问题

    1.想iPad中导入音乐文件,保留原音乐文件名称 [方法]需要删除音乐文件中的“标题”和“参与创作的艺术家”,直接删除的话,效率比较低,需要借助一款软件——foobar2000,选中导入的文件,然后属 ...

  4. Clean Code第二章<命名>

    1.命名要有意义 错误写法 正确写法 2.某些构造函数可以提供有意义的静态方法去实现

  5. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

  6. 用完成例程(Completion Routine)实现的重叠I/O模型

    /// 用完成例程(Completion Routine)实现的重叠I/O模型 /// 异步IO模型 /// 用完成例程来实现重叠I/O比用事件通知简单得多.在这个模型中,主线程只用不停的接受连接 / ...

  7. 粗解Xcode 5新特性: Asset Catalogs

    原文:http://schlu.org/2013/10/01/Xcode-Asset-Catalogs.html 基础知识 在今年的WWDC大会上苹果介绍了Asset Catalogs.Asset C ...

  8. vss使用详解

    下面已VSS6.0为主: 一:安装VSS6.0 安装过程中可能会提示 退出,禁止(abort)  重试(retry)  忽略,跳过(Ignore)  ,我们选 Ignore  跳过此项, 路径自己选择 ...

  9. OC:关于Itunes你了解多少?

    在苹果电脑里有一个 iTunes 简单的说iTunes是苹果公司开发的一个应用程序,由苹果电脑在2001年1月10日于旧金山的 Macworld Expo 推出的一款数字媒体播放应用程序,用于播放以及 ...

  10. CountDownLatch和CyclicBarrier的区别

    [CountDownLatch.CyclicBarrier和Semaphore]http://www.cnblogs.com/dolphin0520/p/3920397.html   [CountDo ...