有关c#继承问题,如何修改以下程序
添加语句,使得能够选择性输出信息。例如,输入book和mage,跳出不同的信息。这里是选择输出书的属性和出版社的属性using System;
using System.Collections.Generic;
using System.Text;
namespace SX01
{
class catalogue //基类
{
public string title;
public string writer;
public string date;
public void print_V()
{
Console.WriteLine("标题是什么?");
this.title = Console.ReadLine();
Console.WriteLine("作者是谁?");
this.writer = Console.ReadLine();
Console.WriteLine("发布时间是多少?");
this.date = Console.ReadLine();
}
public void display()
{
Console.WriteLine();
Console.WriteLine("标题是{0}", this.title);
Console.WriteLine("作者是{0}", this.writer);
Console.WriteLine("发布日期是{0}", this.date);
}
class articles : catalogue
{
string name;
string number;
public void print_A()
{
base.print_V();
Console.WriteLine("杂志名称是什么?");
this.name = Console.ReadLine();
Console.WriteLine("杂志刊号是什么?");
this.number = Console.ReadLine();
}
public void displayskill()
{
base.display();
Console.WriteLine();
Console.WriteLine("名称是{0}", this.name);
Console.WriteLine("刊号是{0}", this.number);
}
}
class books : catalogue
{
string cbmc;
string cbdz;
public void print_B()
{
base.print_V();
Console.WriteLine("出版社叫什么?");
this.cbmc = Console.ReadLine();
Console.WriteLine("出版地址是哪里?");
this.cbdz = Console.ReadLine();
}
public void displayskilled()
{
base.display();
Console.WriteLine();
Console.WriteLine("出版社是{0}", this.cbmc);
Console.WriteLine("出版地址是{0}", this.cbdz);
}
}
class Program
{
static void Main(string[] args)
{
articles art = new articles();
art.print_A();
art.displayskill();
books bo = new books();
bo.print_B();
bo.displayskilled();
}
}
}
}