namespace ConsoleApp1
{
struct Student
{
public string Name;
public string GroupName;
public DateTime BirthDay;
public Dictionary<string, byte> Marks;
public Student(string name, string groupname, DateTime birthday)
{
Name = name;
GroupName = groupname;
BirthDay = birthday;
Marks = new Dictionary<string, byte>();
}
public string ToString(bool isFullInfo)
{
string res = "";
res += String.Format("{0,15} {3}.{2}.{1}r. {4}", Name, BirthDay.Year, BirthDay.Month, BirthDay.Day, GroupName);
if (isFullInfo)
{
foreach (KeyValuePair<string, byte> m in Marks)
res += String.Format("\n{0} - {1}", m.Key, m.Value);
}
return res;
}
class Program
{
static void Main(string[] args)
{
string[] Subjects = new string[] { "Физика", "История", "Информатика" };
List<Student> students = new List<Student>();
Student n1 = new Student("Николай", "18-ИНН", new DateTime(2000, 02, 12));
n1.Marks.Add("Физика", 4);
n1.Marks.Add("История", 4);
n1.Marks.Add("Информатика", 5);
Student n2 = new Student("Денис", "18-ИАС", new DateTime(2000, 03, 25));
students.Add(n2);
n2.Marks.Add("Физика", 2);
n2.Marks.Add("История", 4);
n2.Marks.Add("Информатика", 4);
Student n3 = new Student("Александр", "18-ИСТ", new DateTime(2000, 05, 19));
students.Add(n3);
n3.Marks.Add("Физика", 5);
n3.Marks.Add("История", 5);
n3.Marks.Add("Информатика", 5);
Console.WriteLine("Меню: \n1) Список студентов \n2) Список задолжников \n3) Список студентов с повышенной стипендией");
int menu = Convert.ToByte(Console.ReadLine());
switch (menu)
{
case 1:
for (int i = 0; i < students.Count; i++)
{
Console.WriteLine("Имя: {0} Группа: {1} Дата рождения: {2}", students[i].Name + "\t", students[i].GroupName + "\t", students[i].BirthDay + "\t");
}
break;
case 2:
foreach (Student s in students)
{
}
break;
}
Console.ReadKey();
}
}
}
}
public string ShortFormat()
{
return string.Format("{0,15} {1} {2}", Name, BirthDay.ToShortDateString(), GroupName);
}
public override string ToString()
{
StringBuilder sb = new StringBuilder(ShortFormat());
sb.AppendLine("\nОценки:");
foreach (var m in Marks)
sb.AppendFormat("{0} - {1}\n", m.Key, m.Value);
return sb.ToString();
}
public bool HasDebt => Marks.ContainsValue(2);
switch (menu)
{
case 1:
foreach (var student in students)
Console.WriteLine(student);
break;
case 2:
foreach (var student in students.Where(s => s.HasDebt))
Console.WriteLine(student.ShortFormat());
break;
}