class EnumStruct
{
//定义QQ的状态枚举 Qme QnLine OffLine Leave Busy
//提示用户现在一个状态 然后接收 ,并将用户输入转换成枚举类
enum Qstar
{
Qme,
QnLine,
OffLIne,
Leave,
Busy
} public void QqStar()
{
Console.WriteLine("请选择您的QQ状态:1.Qme 2.QnLine 3.OffLine 4.Leave 5.Busy"); int star = int.Parse( Console.ReadLine()); Qstar myqstar = new Qstar(); switch(star)
{
case :
myqstar = Qstar.Qme;break;
case :
myqstar = Qstar.QnLine; break;
case :
myqstar = Qstar.OffLIne; break;
case :
myqstar = Qstar.Leave; break;
case :
myqstar = Qstar.Busy; break;
default:
Console.WriteLine("您输入不正确!");
break; } Console.WriteLine("您当前的状态为:"+myqstar); }
//用结构体描述一个二维坐标
struct Vector2
{
public int x;
public int y;
} //描述一个矩形的周长和位置
struct Rectangle
{
Vector2 siex;
int x;
int y; }
public void CoorDinate()
{ Vector2 point = new Vector2();
point.x = ;
point.y = ;
Console.SetCursorPosition(point.x*,point.y);
Console.WriteLine("■"); }
//可以自由移动的物体
public void Plain()
{
Rectangle rectangle = new Rectangle();
rectangle.siex.x = 2;
rectangle.siex.y = 3;
Console.Write("■");
while (true)
{
char direction = Console.ReadKey(true).KeyChar;//监听方向键
switch (direction)
{
case 'w':
rectangle.siex.y--; break;
case 's':
rectangle.siex.y++; break;
case 'a':
rectangle.siex.x++; break;
case 'd':
rectangle.siex.x--; break;
default:
break;
}
Console.Clear();//清楚缓存画面
for (int i = 0; i < rectangle.siex.x; i++)//重新定义位置
{
for (int j = 0; j < rectangle.siex.y; j++)
{
if (rectangle.siex.x > 0 && rectangle.siex.y > 0)
{
Console.SetCursorPosition((rectangle.siex.x + i) * 2, rectangle.siex.y + j);
}
}
}
Console.Write("■");//绘制物体
}
}
}