zoukankan      html  css  js  c++  java
  • 第二节

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace Txst2_1
    {
    class Animal
    {
    private Boolean m_sex;
    private int m_age;
    public bool Sex
    {
    get { return m_sex; }
    set { m_sex = false; }
    }
    public int Age
    {
    get { return m_age; }
    set { m_age = value; }
    }
    public virtual string Introduce()
    {
    if (Sex == true)
    return "This is a male Animal";
    else
    return "This is a female Animal";
    }
    }
    class Dog:Animal
    {
    public Dog()
    {
    Sex = true;
    }
    public override string Introduce()
    {
    if (Sex == true)
    return "This is a male Dog";
    else
    return "This is a female Dog";
    }
    }
    class Cat:Animal
    {
    public override string Introduce()
    {
    if (Sex == true)
    return "This is a male Cat";
    else
    return "This is a female Cat";
    }
    }
    class Program
    {
    static void Main(string[] args)
    {
    Animal ani = new Animal();
    Console.WriteLine(ani.Introduce());
    Animal dog = new Dog();
    Console.WriteLine(dog.Introduce());
    Animal cat = new Cat();
    Console.WriteLine(cat.Introduce());
    Console.Read();
    }
    }
    }

  • 相关阅读:
    c语言排序算法
    冒泡 选择排序
    冒泡排序算法
    Pandas数据预处理
    Mongodb的安装和配置
    Mysql练习题
    5 根据过去的行为能否预测当下
    Sklearn逻辑回归
    4 如何通过各种广告组合获取更多的用户
    Sklearn多元线性回归
  • 原文地址:https://www.cnblogs.com/zjk123/p/7538411.html
Copyright © 2011-2022 走看看