• 第十一天学习内容 综合应用 网吧管理系统


    using System;
    using System.Collections;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace day11
    {
        class Class1
        {
          
            struct huiyuan  //定义一个会员的结构体
            {
                public string name;
                public string mima;
                public double yue;
            }
            static void Main(string[] args)
            {
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.White;
                Console.Clear();
                ArrayList hy = new ArrayList(); //新建一个hy的集合用来存放会员信息
                Console.WriteLine("********************一网情深网吧欢迎您*************************");
                Console.WriteLine();
                while (true)
                {


                    Console.WriteLine("请选择您要执行的操作:1、会员管理 2、充值管理");
                    int n = Convert.ToInt32(Console.ReadLine());
                    xz(n,hy);   //调用选择函数 把输入的数字和存放会员的集合传进去
                }
            }
            /// <summary>
            /// 选择函数
            /// </summary>
            /// <param name="n"></param>
            /// <param name="hy"></param>
            static public void xz(int n ,ArrayList hy)
            {
                switch (n)
                {
                    case 1: //如果输入的数字为1,则进行以下操作
                        Console.WriteLine("请选择你要执行的操作:1、新增会员  2、删除会员  3、余额查询");
                        int x = Convert.ToInt32(Console.ReadLine());
                        hygl(x,hy); //输入数字后调用会员管理函数
                        break;
                    case 2: //如果输入的数字为2,则进行以下操作
                         Console.WriteLine("请选择你要执行的操作:1、充值服务  2、扣费服务");
                        int y = Convert.ToInt32(Console.ReadLine());
                        czgl(y,hy);//输入数字后调用充值管理函数
                        break;
                    default:
                        break;
                }
            }
            /// <summary>
            /// 会员管理函数
            /// </summary>
            /// <param name="n"></param>
            /// <param name="hy"></param>
            static public void hygl(int n ,ArrayList hy)
            {
               
                switch (n)
                {
                    case 1://如果输入的数字为1,则进行以下操作
                        huiyuan m = new huiyuan();  //新建一个huiyuan的结构体类型
                        Console.Write("请输入你的用户名:");
                        m.name = Console.ReadLine();
                        Console.Write("请输入你的密码:");
                        m.mima = Console.ReadLine();
                        m.yue = 0;
                        hy.Add(m);//把输入的信息添加到hy的集合中
                        Console.WriteLine("新建会员成功!");
                        Console.WriteLine();
                        break;
                    case 2://如果输入的数字为2,则进行以下操作
                        Console.Write("请输入你想要删除的用户名:");
                        string ss = Console.ReadLine();
                        for (int i = 0; i < hy.Count; i++)
                        {
                            if (ss==((huiyuan)hy[i]).name)//如果输入的用户名和hy集合中的用户名相同
                            {
                                hy.RemoveAt(i);//则移除hy集合中该元素
                                Console.WriteLine("删除会员成功!");
                                break;
                            }
                        }
                        break;
                    case 3:
                        Console.Write("请输入你想要查询余额的用户名:");
                          string s = Console.ReadLine();
                        for (int i = 0; i < hy.Count; i++)
                        {
                            if (s == ((huiyuan)hy[i]).name)//如果输入的用户名和hy集合中的用户名相同
                            {
                                Console.WriteLine("用户名:"+((huiyuan)hy[i]).name+" 余额:"+((huiyuan)hy[i]).yue);
                                break;
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            /// <summary>
            /// 充值管理函数
            /// </summary>
            /// <param name="n"></param>
            /// <param name="hy"></param>
            static public void czgl(int n, ArrayList hy)
            {
                switch (n)
                {
                    case 1:
                        huiyuan temp = new huiyuan();  //新建一个临时的huiyuan结构体类型的temp
                        Console.Write("请输入你要充值的用户名:");
                        string a = Console.ReadLine();
                        for (int i = 0; i < hy.Count; i++)
                        {
                            if (a == ((huiyuan)hy[i]).name)
                            {
                                temp = ((huiyuan)hy[i]);//如果输入的用户名和hy集合中的用户名相同,就把集合中的该元素赋给temp
                                Console.WriteLine("用户名:" + temp.name + " 余额:" + temp.yue);
                                Console.Write("请输入您要充值的金额:");
                               
                                double m = Convert.ToDouble(Console.ReadLine());
                                int jl = 0; //充值奖励办法
                                if (m < 10)
                                {

                                    jl = 0;
                                }
                                else if (m >= 10 && m < 20)
                                {
                                    jl = 2;
                                }
                                else if (m >= 20 && m < 50)
                                {
                                    jl = 5;
                                }
                                else if (m >= 50 && m < 100)
                                {
                                    jl = 15;
                                }
                                else if (m >= 100 && m < 200)
                                {
                                    jl = 50;
                                }
                                else if (m >= 200 && m < 300)
                                {
                                    jl = 150;
                                }
                                else if (m >= 300)
                                {
                                    jl = Convert.ToInt32(m);
                                }
                                temp.yue +=(m + jl);//判断完成后重新计算余额
                                hy.Insert(i, temp);//把temp插入到索引i的位置
                                hy.RemoveAt(i + 1);//并把原先的元素删掉(这是集合中更新数据的方法,插入新数据删掉原先的数据)
                                Console.WriteLine("用户名:" + temp.name + " 充值后余额:" + temp.yue);
                                break; 
                            }

           
                           
                        }
                        break;
                   

                    default:
                        break;
                }

            }
        }
    }

  • 相关阅读:
    Todo
    我的类
    Python socket编程之七:多窗口的应用
    iOS与PHP/Android AES128 ECB NoPadding加密
    JSONModel简便应用
    iOS开发系列--UITableView全面解析
    常用方法
    OC和C++混编
    数据层
    block
  • 原文地址:https://www.cnblogs.com/William-1234/p/4334226.html
Copyright © 2020-2023  润新知