您的位置:首页 > 运维架构

定义父亲类Father(姓lastName,财产property,血型bloodType),儿子Son类(玩游戏PlayGame方法),女儿Daughter类(跳

2016-09-06 10:38 218 查看
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace _02C基础加强

{

    class Program

    {

        static void Main(string[] args)

        {

            //作业:定义父亲类Father(姓lastName,财产property,血型bloodType),儿子Son类(玩游戏PlayGame

           // 方法),女儿Daughter类(跳舞Dance发法),调用父类构造函数(:base())给子类字段赋值

        }

    }

    class Father

    {

        public string LastName { get; set; }

        public double Property { get; set; }

        public string bloodType { get; set;}

        public Father(string lastName, double property, string bloodType)

        {

            this.LastName = lastName;

            this.Property = property;

            this.bloodType = bloodType;

        }

    }

    class son : Father

    {

        public son(string lastName, double property, string bloodType)

            : base(lastName, property, bloodType)

        { 

        }

        public void PlayGame()

        {

            Console.WriteLine("儿子可以玩游戏!");

        }

    }

    class Daughter : Father

    {

        public Daughter(string lasteName, double property, string bloodType)

            : base(lasteName, property, bloodType)

        { 

        

        }

        public void Dance()

        {

            Console.WriteLine("我会跳舞!");

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# 面向对象
相关文章推荐