using System;
namespace ConsoleApp2
{
internal class Program
{
private static void Main(string[] args)
{
Student zhangSan = new Student("张三", 18u, true, 10001u);
zhangSan.DisplayInfo();
Console.ReadKey();
}
}
internal abstract class Person
{
protected string name;
protected uint age;
protected bool gender;
protected Person(string name, uint age, bool gender)
{
this.name = name;
this.age = age;
this.gender = gender;
}
}
internal class Student : Person
{
private uint id;
public uint Id { get => id; set => id = value; }
public Student(string name, uint age, bool gender, uint id) : base(name, age, gender)
{
Id = id;
}
public void DisplayInfo()
{
Console.WriteLine(ToString());
}
public override string ToString()
{
string genderValue = gender ? "男" : "女";
return $"姓名:{name}{Environment.NewLine}"
+ $"年龄:{age}岁{Environment.NewLine}"
+ $"性别:{genderValue}{Environment.NewLine}"
+ $"学号:{id}";
}
}
}