.NET程序天下

web程序设计...

导航

刷卡练习

 

 1//----------------------------------------------------------------------
 2/* 文件名称:BrushCard.cs;
 3 * 输入:身份;
 4 * 输出:相应身份问候;
 5 * 描述:实现在不同时段,不同身份人物,发出不同问候;
 6 * 制作:Txun;
 7 * 时间:04/20/2007;
 8 */

 9//----------------------------------------------------------------------
10
11using System;
12
13namespace Txun
14{
15    //程序入口点
16    class EntryPoint
17    {
18        static void Main()
19        {
20            BrushCard.JudgeTime();
21        }

22    }

23    //刷卡类
24    class BrushCard
25    {
26        //判断时间函数
27        public static void JudgeTime()
28        {
29            Console.WriteLine("选择你的身份\n1.老板\t2.员工\t3.雇员");
30            int NowTime = DateTime.Now.Hour;
31            bool isValid = true;
32            do
33            {
34                string identity = Console.ReadLine();
35                if (7 <= NowTime && NowTime < 9)
36                {
37                    JudgeIdentity(identity, ref isValid, "早上好,新的一天开始了!");
38                }

39                else if (9 <= NowTime && 12 > NowTime)
40                {
41                    JudgeIdentity(identity, ref isValid, "现在是上午上班时间,COME ON!");
42                }

43                else if (12 <= NowTime && 14 > NowTime)
44                {
45                    JudgeIdentity(identity, ref isValid, "现在是午休时间,请注意休息!");
46                }

47                else if (14 <= NowTime && 19 > NowTime)
48                {
49                    JudgeIdentity(identity, ref isValid, "现在是下午上班时间,COME ON!");
50                }

51                else
52                {
53                    JudgeIdentity(identity, ref isValid, "辛苦了,现在是加班时间,COME ON!");
54                }

55
56            }

57            while (isValid == false);
58        }

59
60        //判断身份函数
61        private static void JudgeIdentity(string strIdentity, ref bool bIsValid, string strGreet)
62        {
63            switch (strIdentity)
64            {
65                case "1":
66                    Console.WriteLine("老板." + strGreet);
67                    bIsValid = true;
68                    break;
69                case "2":
70                    Console.WriteLine("员工." + strGreet);
71                    bIsValid = true;
72                    break;
73                case "3":
74                    Console.WriteLine("雇员." + strGreet);
75                    bIsValid = true;
76                    break;
77                default:
78                    Console.WriteLine("输入错误,请重新选择!");
79                    bIsValid = false;
80                    break;
81            }

82        }

83    }

84}

 

posted on 2007-04-20 17:30  酷小涛  阅读(215)  评论(0编辑  收藏  举报