using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Student_c_
{
enum Week : int
{
Mon,
Tus,
Wed,
Thu,
Fri,
Sat,
Sun,
}
public class Student
{
public static string Course = "面向对象程序设计!";
public static string Where = "G2-407";
public string Name { get; set; }
public string ClassName { get; set; }
private int Id;
// 班级的最大容量,这是一个常量
public const int MaxNum = 39;
public bool flag = true;
// 学生的ID
public int id
{
get
{
return Id;
}
set
{
if(value >MaxNum||value <0)
{
Console.WriteLine("学号输入错误");
flag = !flag;
}
else
{
Id = value;
}
}
}
// 构造函数
public Student( int id,string name, string className)
{
this.id=id;
Name = name;
ClassName = className;
}
internal class Program
{
public static void GotoClass(Student stu)
{
if(stu.flag)
{
Console.WriteLine("学号是:{2} 班级是:{0} 姓名是:{1}", stu.ClassName, stu.Name, stu.Id);
}
else
{
Console.WriteLine(" 班级是:{0} 姓名是:{1}", stu.ClassName, stu.Name);
}
}
static void Main(string[] args)
{
string a, b;
int c;
string day;
Console.WriteLine("输入学号:");
c = int.Parse(Console.ReadLine());
Console.WriteLine("输入班级:");
a = Console.ReadLine();
Console.WriteLine("输入姓名:");
b = Console.ReadLine();
Console.WriteLine("今天是星期几:");
day = Console.ReadLine();
Console.WriteLine("\n");
// Week worday=(Week)Enum.Parse(typeof(Week), day);
if (Enum.TryParse<Week>(day, true, out Week workday))//
{
if (workday == Week.Sat||workday==Week.Sun)
{
Console.WriteLine("Today is weekend!!!");
}
else
{
Console.WriteLine("Today is {0}", day);
}
}
Student stu = new Student(c, b, a);
GotoClass(stu);
Console.WriteLine($"课程是:{Course} 教室是:{Where}");
Console.ReadLine();
}
}
}
}