///注释可以让人看到说明
如果是变量,就要类型强转。
///注释可以让人看到说明
如果是变量,就要类型强转。
/// <summary>
/// QQ状态枚举
/// </summary>
enum E_QQType
{
/// <summary>
/// 在线
/// </summary>
OnLine,
Leave,
Busy,
Invisible,
}
enum E_CoffeeType
{
/// <summary>
/// 中杯
/// </summary>
M,
/// <summary>
/// 大杯
/// </summary>
B,
/// <summary>
/// 超大杯
/// </summary>
S,
}
enum E_Sex
{
/// <summary>
/// 男性
/// </summary>
Man,
/// <summary>
/// 女性
/// </summary>
Female,
}
enum E_Occupation
{
/// <summary>
/// 战士
/// </summary>
Warrior,
/// <summary>
/// 猎人
/// </summary>
Hunter,
/// <summary>
/// 法师
/// </summary>
Master,
}
static void Main(string[] args)
{
#region 练习题一
//定义QQ状态的枚举,并提示用户选择一个在线状态,我们接受输入的数字,并将其转换成枚举类型
//try
//{
// Console.WriteLine("请输入QQ的状态(0在线,1离开,2忙,3隐身)");
// int type = int.Parse(Console.ReadKey().KeyChar.ToString());
// E_QQType qQType = (E_QQType)type;
// Console.WriteLine(qQType);
//}
//catch
//{
// Console.WriteLine("请输入一个正确的数值");
//}
#endregion
#region 练习题二
//用户去星巴克买咖啡 分为中杯(35元),大杯(40元),超大杯(43元),
//请用户选择要购买的类型,用户选择后,打印:您购买了xxx咖啡,花费xx元
//例如:你购买了中杯咖啡,花费了35元
//try
//{
// Console.WriteLine("请输入咖啡的种类(0是中杯,1是大杯,2为超大杯)");
// int cafeType = int.Parse(Console.ReadKey().KeyChar.ToString());
// E_CoffeeType coffeeType = (E_CoffeeType)cafeType;
// switch (coffeeType)
// {
// case E_CoffeeType.M:
// Console.WriteLine("中杯(35)元");
// break;
// case E_CoffeeType.B:
// Console.WriteLine("大杯(40)元");
// break;
// case E_CoffeeType.S:
// Console.WriteLine("超大杯(43)元");
// break;
// default:
// Console.WriteLine("请输入正确类型!");
// break;
// }
//}
//catch
//{
// Console.WriteLine("请输入数字!");
//}
#endregion
#region 练习题三
//请用户选择英雄性别与英雄职业,最后打印英雄的基本属性(攻击力,防御力,技能)
//性别:
//男(攻击力 + 50,防御力 + 100)
//女(攻击力 + 150,防御力 +20)
//职业;
//战士(攻击力 + 20,防御力 + 100,技能:冲锋)
//猎人(攻击力 + 120,防御力 + 30,技能;假死)
//法师(攻击力 + 200,防御力 + 10,技能:奥术冲击)
//举例打印;你选择了“女性法师”,攻击力:350,防御力:30,职业技能:奥术冲击
try
{
Console.WriteLine("请选择性别(男0 女1)");
int sex = int.Parse(Console.ReadLine());
E_Sex sexType = (E_Sex)sex;
string sexStr = "";
int atk = 0;
int def = 0;
switch (sexType)
{
case E_Sex.Man:
sexStr = "男性";
atk += 50;
def += 100;
break;
case E_Sex.Female:
sexStr = "女性";
atk += 150;
def += 20;
break;
default:
Console.WriteLine("请输入正确的数值!");
break;
}
Console.WriteLine("请选择职业(战士0 猎人1 法师2)");
int occupation = int.Parse(Console.ReadLine());
E_Occupation occupationType = (E_Occupation)occupation;
string skill = "";
string o = "";
switch (occupationType)
{
case E_Occupation.Warrior:
atk += 20;
def += 100;
skill = "冲锋";
o = "战士";
break;
case E_Occupation.Hunter:
atk += 120;
def += 30;
skill = "假死";
o = "猎人";
break;
case E_Occupation.Master:
atk += 200;
def += 10;
skill = "奥术冲击";
o = "法师";
break;
default:
Console.WriteLine("请输入正确的数值!");
break;
}
Console.WriteLine($"你选择了{sexStr}{o},攻击力为{atk},防御力为{def},技能为{skill}");
}
catch
{
Console.WriteLine("请输入数字");
}
#endregion
三杠注释可以让它下面最靠近它的变量有鼠标注释