zoukankan      html  css  js  c++  java
  • 网吧充值 函数+Swich+ArrayList版

    namespace ConsoleApplication1
    {
        class Program
        {
            struct huiyuan
            {
                public string name;
                public string password;
                public double yue;
            }
            static void Main(string[] aaa)
            {
                ArrayList Ul = new ArrayList();
                while (true)
                {
                    try
                    {
                        Console.WriteLine("请输入您要执行的操作:(1、会员管理	2、充值管理)");
                        int x = Convert.ToInt32(Console.ReadLine());
                        m(x, Ul);
                    }
                    catch (Exception)
                    {
    
    
                    }
                }
    
            }
            static void m(int x, ArrayList al)
            {
                switch (x)
                {
                    case 1:
                        Console.WriteLine("1、添加会员	2、删除会员	3、余额查询");
                        int xx = Convert.ToInt32(Console.ReadLine());
                        huiyuanfuwu(xx, al);
                        break;
                    case 2:
                        Console.WriteLine("1、充值服务	2、扣费服务");
                        int xxx = Convert.ToInt32(Console.ReadLine());
                        chongzhiguanli(xxx, al);
                        break;
                    default:
                        break;
                }
            }
    
            static void chongzhiguanli(int x, ArrayList al)
            {
                switch (x)
                {
                    case 1:
                        Console.Write("请输入要充值的用户名:");
                        string sname = Console.ReadLine();
                        foreach (huiyuan item in al)
                        {
                            if (item.name == sname)
                            {
    
                                Console.WriteLine("当前余额为:" + item.yue);
                                Console.Write("请输入充值金额:");
                                double m = Convert.ToInt32(Console.ReadLine());
                                chongzhi(m, al, sname);
                                break;
    
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
    
            static void chongzhi(double m, ArrayList al, string sname)
            {
                double x = 0;//奖励金额
    
    
                if (m >= 10 && m < 20)
                {
                    x = 2;
                }
                else if (m >= 20 && m < 50)
                {
                    x = 5;
                }
                else if (m >= 50 && m < 100)
                {
                    x = 20;
                }
                else if (m >= 100 && m < 200)
                {
                    x = 50;
                }
                else if (m >= 200 && m < 300)
                {
                    x = 150;
                }
                else if (m >= 300)
                {
                    x = m;
                }
                else
                {
                    x = 0;
                }
                huiyuan temp = new huiyuan();
                for (int i = 0; i < al.Count; i++)
                {
                    temp = ((huiyuan)al[i]);
                    if (temp.name == sname)
                    {
    
                        temp.yue += Convert.ToDouble(m + x);
                        Console.WriteLine("本次充值成功,充值金额为" + m + "。奖励金额为:" + x + ".充值后余额为:" + temp.yue);
                        al.Insert(i, temp);
                        al.RemoveAt(i + 1);
                        break;
                    }
    
                }
    
            }
            static void huiyuanfuwu(int x, ArrayList al)
            {
                switch (x)
                {
                    case 1:
                        huiyuan h = new huiyuan();
                        Console.Write("请输入用户名:");
                        h.name = Console.ReadLine();
                        Console.Write("请输入密码:");
                        h.password = Console.ReadLine();
                        h.yue = 0;
                        al.Add(h);
                        break;
                    case 2:
                        Console.Write("请输入要删除的用户名:");
                        string dname = Console.ReadLine();
                        foreach (huiyuan item in al)
                        {
                            if (item.name == dname)
                            {
                                al.Remove(item);
                                Console.WriteLine("删除成功!");
                                break;
                            }
                        }
    
                        break;
                    case 3:
                        Console.Write("请输入要查询的用户名:");
                        string sname = Console.ReadLine();
                        foreach (huiyuan item in al)
                        {
                            if (item.name == sname)
                            {
    
                                Console.WriteLine("当前余额为:" + item.yue);
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
    
        }
    }
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    linux三剑客
    linux用户权限
    linux文件权限
    linux目录配置
    linux命令(持续更新)
    linux外置命令
    linux日常操作指令
    晨雾

    CAPTCHA--验证码
  • 原文地址:https://www.cnblogs.com/dlexia/p/4439425.html
Copyright © 2011-2022 走看看