我试图为10名运动员的"运动"抽象课程实例化对象,其中包括每个运动员的名字和年龄,然后有两个派生类别用于"网球"运动员和一个用于"高尔夫"运动员.
class Program
{
static void Main(string[] args)
{
Sport[] athlete = new Sport[10];
athlete[0] = new Tennis("John Smith", 18, "Tennis", 5.0, 92);
athlete[1] = new Tennis("Lisa Townsend", 15, "Tennis");
athlete[2] = new Tennis("Brian Mills", 17, "Tennis", 4.0, 83);
athlete[3] = new Golf("Stacey Bell", 16, "Golf", 10, 20);
athlete[4] = new Golf("Tom Spehr", 18, "Golf", 9, 12);
athlete[5] = new Golf("Sam Calen", 14, "Golf");
athlete[6] = new Tennis("Karen Strong", 17, "Tennis", 3.0, 78);
athlete[7] = new Golf("Ken Able", 15, "Golf", …Run Code Online (Sandbox Code Playgroud)