奋斗不能等待,我们不能等到垂暮之年再去“全力以赴”。让我们从现在开始,为理想而努力,为人生而拼搏。精诚所至,金石为开,相信奋斗会让我们的青春之花绽放得更加绚烂,让我们的人生之路走下来不留遗憾。
一、我带大家看看我的神奇Bank系统思路.
1.我们都知道去银行办理业务都是要有一张属于你自己的卡 所以这里就需要一个卡的类
class Card { private string cardNo;//卡号 private string cardOwner;//持卡人 private string cardPwd;//密码 private double balance;//余额 public double Balance { get { return balance; } set { balance = value; } } public string CardPwd { get { return cardPwd; } set { cardPwd = value; } } public string CardOwner { get { return cardOwner; } set { cardOwner = value; } } public string CardNo { get { return cardNo; } set { cardNo = value; } } }
2.我们去银行就必不可缺少的银行类喽
1.开户 2.存款 3.取款 4.查询余额 5.转账 6.修改密码 7.退出 8.输出所有账户的持卡人以及余额
//开户模块 Console.WriteLine("欢迎进入开户模块"); Console.WriteLine("请输入卡号"); string cardNo = Console.ReadLine(); Console.WriteLine("请输入密码"); string cardPwd = Console.ReadLine(); Console.WriteLine("请输入用户名"); string cardOwner = Console.ReadLine(); Console.WriteLine("请输入开户后要存储的金额"); double balance = double.Parse(Console.ReadLine()); //将bank里的值重新赋给Card中 Card card = new Card(); card.CardNo = cardNo; card.CardPwd = cardPwd; card.CardOwner = cardOwner; card.Balance = balance; //将card对象赋值给数组第一个为null的项目 for (int i = 0; i < cards.Length; i++) { if (cards[i]==null) { cards[i] = card; Console.WriteLine("开户成功!"); break; } } //存款模块 Console.WriteLine("请输入您的账号"); string cardno = Console.ReadLine(); for (int i = 0; i < cards.Length; i++) { if (cards[i] != null && cards[i].CardNo == cardno) { flag = true; Console.WriteLine("请输入密码"); string pwd = Console.ReadLine(); if (cards[i].CardPwd == pwd) { Console.WriteLine("恭喜您登陆成功!请输入您要存款的金额:"); double GiveMoney = double.Parse(Console.ReadLine()); cards[i].Balance = cards[i].Balance + GiveMoney; Console.WriteLine("恭喜您存款成功,您的当前余额为:{0}", cards[i].Balance); break; } else { Console.WriteLine("您输入的密码有误!"); break; } } } //取款模块 Console.WriteLine("请输入您的账号"); string cardno = Console.ReadLine(); for (int i = 0; i < cards.Length; i++) { if (cards[i] != null && cards[i].CardNo == cardno) { flag1 = true; Console.WriteLine("请输入密码"); string pwd = Console.ReadLine(); if (cards[i].CardPwd == pwd) { Console.WriteLine("恭喜您登陆成功!请输入您要取款的金额:"); double TakeMoney = double.Parse(Console.ReadLine()); cards[i].Balance = cards[i].Balance - TakeMoney; Console.WriteLine("恭喜您存款成功,您的当前余额为:{0}", cards[i].Balance); break; } else { Console.WriteLine("您输入的密码有误!"); break; } } } //转账模块 注意!注意!我手写三遍的 Console.WriteLine("请输入您的账号"); string cardno = Console.ReadLine(); for (int i = 0; i < cards.Length; i++) { if (cards[i] != null && cards[i].CardNo == cardno) { flag2 = true; Console.WriteLine("请输入密码"); string pwd = Console.ReadLine(); if (cards[i].CardPwd == pwd && cards[i].Balance!=0) { if (cards[i].Balance!=0) { Console.WriteLine("恭喜您登陆成功!请输入您要转账的对象账户:"); string Target = Console.ReadLine(); for (int j = 0; j < cards.Length; j++) { if (cards[j].CardNo.Equals( Target) || cards[j].CardNo!=null ) { Console.WriteLine("请输入您的操作金额:"); double Transform = double.Parse(Console.ReadLine()); if (Transform < cards[i].Balance && Transform != 0) { cards[i].Balance -= Transform; cards[j].Balance += Transform; Console.WriteLine("恭喜您转账成功!您的当前余额为:{0}", cards[i].Balance); break; } else { Console.WriteLine("请输入正确的操作金额:"); } } break; } break; } else { Console.WriteLine("您当前的余额不足!不能进行转账!"); } } else { Console.WriteLine("您输入的密码有误!"); break; } } } return flag2; } //查询余额 public bool SelectMoney() { bool flag3 = false; Console.WriteLine("==================="); Console.WriteLine("这里是查询余额模块"); Console.WriteLine("==================="); Console.WriteLine("请输入您的账号"); string cardno = Console.ReadLine(); for (int i = 0; i < cards.Length; i++) { if (cards[i] != null && cards[i].CardNo == cardno) { flag3 = true; Console.WriteLine("请输入密码"); string pwd = Console.ReadLine(); if (cards[i].CardPwd == pwd) { Console.WriteLine("恭喜您登陆成功!您的当前余额为:{0}:",cards[i].Balance); Welcome(); break; } else { Console.WriteLine("您输入的密码有误!"); break; } } } //修改密码 复制代码 Console.WriteLine("请输入您的账号"); string cardno = Console.ReadLine(); for (int i = 0; i < cards.Length; i++) { if (cards[i] != null && cards[i].CardNo == cardno) { flag4= true; Console.WriteLine("请输入你的密码"); string pwd = Console.ReadLine(); if (cards[i].CardPwd == pwd) { Console.WriteLine("请输入您的新密码:"); string pwd3=Console.ReadLine(); Console.WriteLine("请再次输入您的新密码:"); string pwd2=Console.ReadLine(); if (pwd2==pwd3) { cards[i].CardPwd = pwd3; } Console.WriteLine("恭喜您密码修改成功!您的新密码是{0}",cards[i].CardPwd); Welcome(); break; } else { Console.WriteLine("您输入的密码有误!"); break; } } }
3.退卡相信大家都会啦吧,我就略啦哈......
我的小思路与大家分享如果有错误希望大家可以多多指教
总结:乐学实学,挑战自己;勤勉向上,成就自我。
时间: 2024-12-15 01:42:49