简单的银行系统

    欢迎来到unity学习unity培训unity企业培训教育专区,这里有很多U3D资源U3D培训视频U3D教程U3D常见问题U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。

    今天我们来一起回顾一下简单的银行系统,主要复习一下以前学习的【方法的调用】

    想要写个简单的银行系统呢,首先要有一个大概的思路:

    1.开户

    2.登录

    3.存取款

    4.查询余额

    5.销户

    下面我们来用代码实现一下这些步骤:

  1. class Program
  2.     {
  3.         string id = "102",password = "123";
  4.         int  balance = 10;
  5.         public void Open()
  6.         {
  7.             int b=1;
  8.             string c = Console.ReadLine();
  9.             int d = int.Parse(c);
  10.             if (d == b)
  11.             {
  12.                 Console.WriteLine("已开户");
  13.             }
  14.             else
  15.             {
  16.                 Console.WriteLine("未开户");
  17.             }
  18.         }
  19.         public void Login(string id,string password)
  20.         {
  21.             if (password=="123"&&id=="102")
  22.             {
  23.                 Console.WriteLine("登录成功");
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("登录失败");
  28.             }

  29.         }
  30.         public void Save(int money)
  31.         {
  32.             balance = balance + money;
  33.             Console.WriteLine("存款成功");
  34.         }
  35.         public void Get(int m)
  36.         {
  37.             balance = balance - m;
  38.             Console.WriteLine("取款成功");
  39.         }
  40.         public void Query()
  41.         {
  42.             Console.WriteLine(balance);
  43.         }
  44.         public void Close()
  45.         {
  46.             id = "0";
  47.             password = null;
  48.             balance = 0;
  49.         }
  50.         public void Show()
  51.         {
  52.             
  53.             Console.WriteLine("1.开户");
  54.             Console.WriteLine("2.登录");
  55.             Console.WriteLine("3.存款");
  56.             Console.WriteLine("4.取款");
  57.             Console.WriteLine("5.查询余额");
  58.             Console.WriteLine("6.销户");
  59.             string a= Console.ReadLine();

  60.             switch (a)
  61.             {
  62.                 case "1":
  63.                     Console.WriteLine("是否进行开户?开户请输入1");

  64.                 Open();
  65.                 Show();
  66.                 break;

  67.                 case "2":
  68.                     Console.WriteLine("请输入id:");
  69.                 string id= Console.ReadLine();

  70.                 Console.WriteLine("请输入密码:");
  71.                 string password = Console.ReadLine();
  72.                 Login(id,password);
  73.                 Show();
  74.                 break;

  75.                 case "3":
  76.                 Console.WriteLine("请输入存款金额:");
  77.                 int money=int.Parse(Console.ReadLine());
  78.                 Save(money);
  79.                 Show();
  80.                 break;

  81.                 case "4":
  82.                 Console.WriteLine("请输入取款金额:");
  83.                 int m=int.Parse(Console.ReadLine());
  84.                 Get(m);
  85.                 Show();
  86.                 break;

  87.                 case "5":
  88.                 Console.WriteLine("您的余额为:");
  89.                 Query();
  90.                 Show();
  91.                 break;

  92.                 case "6":
  93.                 Console.WriteLine("已为您销户");
  94.                 Close();
  95.                 break;

  96.                 default:
  97.                 break;
  98.             }
  99.             
  100.         }
  101.         static void Main(string[] args)
  102.         {
  103.             Program p = new Program();
  104.             p.Show();
  105.                
  106.         }
  107.     }
今天学习感悟:
   在学习U3D的过程中呢,要注意打好C#基础,切忌心浮气躁,每个人的起点都不同,但是心态决定最后的结果。所以一定不能懈怠,虽然之前已经学会了方法的调用,但是今天做的小小的银行系统就被难住的我,还是要继续学习方法的调用,为我的未来奠定好每一块基石!
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值