寻找C#大神,寻找问题答案
答案:2 悬赏:70 手机版
解决时间 2021-04-05 15:11
- 提问者网友:温柔港
- 2021-04-04 16:41
寻找C#大神,寻找问题答案
最佳答案
- 五星知识达人网友:纵马山川剑自提
- 2021-04-04 17:23
///
/// 物种
///
public abstract class Species
{
///
/// 名称
///
public abstract string Name
{
get;
}
///
/// 类别
///
public abstract string Type
{
get;
}
}
///
/// 动物
///
public abstract class Animal : Species
{
///
/// 类别
///
public override string Type
{
get { return "动物"; }
}
///
/// 获取叫声
///
public abstract string GetHue();
///
/// 叫
///
public void Cry()
{
Console.WriteLine("{0}叫:{1}", Name, GetHue());
}
}
///
/// 植物
///
public abstract class Plant : Species
{
///
/// 种类
///
public override string Type
{
get { return "植物"; }
}
///
/// 颜色
///
public string Color
{
get;
protected set;
}
}
///
/// 猫
///
public class Cat : Animal
{
///
/// 名称
///
public override string Name
{
get { return "猫"; }
}
///
/// 叫声
///
public override string GetHue()
{
return "喵喵";
}
}
///
/// 狮子
///
public class Lion : Animal
{
///
/// 名称
///
public override string Name
{
get { return "狮子"; }
}
///
/// 叫声
///
public override string GetHue()
{
return "喵";
}
}
///
/// 玫瑰
///
public class Rose : Plant
{
public Rose(string color)
{
Color = color;
}
///
/// 名称
///
public override string Name
{
get { return "玫瑰"; }
}
}
///
/// 松树
///
public class Pine : Plant
{
public Pine(string color)
{
Color = color;
}
///
/// 名称
///
public override string Name
{
get { return "松树"; }
}
}
/// 物种
///
public abstract class Species
{
///
/// 名称
///
public abstract string Name
{
get;
}
///
/// 类别
///
public abstract string Type
{
get;
}
}
///
/// 动物
///
public abstract class Animal : Species
{
///
/// 类别
///
public override string Type
{
get { return "动物"; }
}
///
/// 获取叫声
///
public abstract string GetHue();
///
/// 叫
///
public void Cry()
{
Console.WriteLine("{0}叫:{1}", Name, GetHue());
}
}
///
/// 植物
///
public abstract class Plant : Species
{
///
/// 种类
///
public override string Type
{
get { return "植物"; }
}
///
/// 颜色
///
public string Color
{
get;
protected set;
}
}
///
/// 猫
///
public class Cat : Animal
{
///
/// 名称
///
public override string Name
{
get { return "猫"; }
}
///
/// 叫声
///
public override string GetHue()
{
return "喵喵";
}
}
///
/// 狮子
///
public class Lion : Animal
{
///
/// 名称
///
public override string Name
{
get { return "狮子"; }
}
///
/// 叫声
///
public override string GetHue()
{
return "喵";
}
}
///
/// 玫瑰
///
public class Rose : Plant
{
public Rose(string color)
{
Color = color;
}
///
/// 名称
///
public override string Name
{
get { return "玫瑰"; }
}
}
///
/// 松树
///
public class Pine : Plant
{
public Pine(string color)
{
Color = color;
}
///
/// 名称
///
public override string Name
{
get { return "松树"; }
}
}
全部回答
- 1楼网友:忘川信使
- 2021-04-04 18:30
请看附件的源代码。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯