标题:【高分】拜求一个c#程序(高人请进)
只看楼主
ss637315
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-6-12
结帖率:0
已结贴  问题点数:5 回复次数:2 
【高分】拜求一个c#程序(高人请进)
定义Teacher(教师)类和Cadre(干部)接口,再定义Teacher_Cadre(教师兼干部)类以继承Teacher类和实现Cadre接口。
要求:1.在Teacher类中包括变量成员Name(姓名),Sex(性别),Age(年龄),Tttle(职称),Add(地址),Tel(电话)和方法成员Display用以输出教师的姓名,性别,电话。2.在Cadre接口中包括属性成员Post(职务)3.用Teacher_Cadre类的方法成员Show调用Teacher类中的Display方法,输出教师的姓名,性别,年龄,职务,地址,电话。4.用来测试类和接口功能的方法Main必须放在Teacher_Cadre类中。
搜索更多相关主题的帖子: 高分 高人 
2010-06-12 13:22
chenkb730
Rank: 2
等 级:论坛游民
帖 子:39
专家分:44
注 册:2010-3-22
得分:2 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 面向对象练习
{
    public interface Cadre
    {
        string Post
        {
            
            get;
        }
    }
    public class Teacher
    {
        string name;
        string sex;
        int age;
        string title;
        string address;
        int tel;
        public Teacher() { }
        public Teacher(string name, string sex, int age, string title, string address, int tel)
        {
            this.name = name;
            this.sex = sex;
            this.age = age;
            this.title = title;
            this.address = address;
            this.tel = tel;
        }
        public void Display()
        {
            Console.WriteLine( "姓名:{0},性别:{1}年龄:{2}职称:{3}地址:{4}电话:{5}",name,sex ,age ,title ,address ,tel );
        }
    }
    public class Teacher_Cadre : Teacher, Cadre
    {
        public Teacher_Cadre(string name, string sex, int age, string title, string address, int tel)
            : base(name,sex, age, title, address, tel)
        {
 
        }
        public string Post
        {

            get { return "经理:"; }
        }
        public void Show()
        {
           Console.Write("职务:{0}",Post);
            Display();
        }


        static void Main(string[] args)
        {
            Teacher_Cadre tom = new Teacher_Cadre("tom","男",20,"经理","广东",123456);
            tom.Show();
        }
    }
    }
2010-06-19 11:23
zhenxiaoyan
Rank: 2
等 级:论坛游民
帖 子:22
专家分:40
注 册:2009-8-24
得分:2 
回复 楼主 ss637315
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 面向对象练习
{
    public interface Cadre
    {
        string Post
        {
            
            get;
        }
    }
    public class Teacher
    {
       private string name;
       public string Name
       {
          get{return name;}
          set{name=value;}
        }
       private string sex;
        public string Sex
       {
          get{return sex;}
          set{sex=value;}
        }

       private int age;
       public int Age
       {
          get{return age;}
          set{age=value;}
        }

       private string title;
       public string Title
      {
          get{return title;}
          set{title=value;}
        }

       private string address;
       public string Address
       {
          get{return address;}
          set{address=value;}
        }

       private int tel;
       public int Tel
       {
          get{return tel;}
          set{tel=value;}
        }

        public Teacher() { }
        public Teacher(string name, string sex, int age, string title, string address, int tel)
        {
            this.Name = name;
            this.Sex = sex;
            this.Age = age;
            this.Title = title;
            this.Address = address;
            this.tel = tel;
        }
        public void Display()
        {
            Console.WriteLine( "姓名:{0},性别:{1}年龄:{2}职称:{3}地址:{4}电话:{5}",name,sex ,age ,title ,address ,tel );
        }
    }
    public class Teacher_Cadre : Teacher, Cadre
    {
        public Teacher_Cadre(string name, string sex, int age, string title, string address, int tel)
            : base(name,sex, age, title, address, tel)
        {

        }
        public string Post
        {

            get { return "经理:"; }
        }
        public void Show()
        {
           Console.Write("职务:{0}",Post);
            Display();
        }


        static void Main(string[] args)
        {
            Teacher_Cadre tom = new Teacher_Cadre("tom","男",20,"经理","广东",123456);
            tom.Show();
        }
    }
    }
2010-06-20 19:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-310066-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.241437 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved