• 网吧充值 函数+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;
                }
            }
    
        }
    }
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    execution(* *..BookManager.save(..))的解读
    metalink下载补丁包
    loop_login.sh
    EXPDP IMPDP 知识总结
    图书管理系统简单 过程
    Data Types
    Oracle 创建分页存储过程(转帖)
    绑定变量赋值
    Oracle10g、 Oracle11g完美共存
    Oracle11G 数据库 expdp、impdp使用示例
  • 原文地址:https://www.cnblogs.com/dlexia/p/4439425.html
Copyright © 2020-2023  润新知