为了账号安全,请及时绑定邮箱和手机立即绑定

老师源代码谁有吗?

哪位大哥,把老师的源码复制一下给我看看,谢谢了

正在回答

1 回答

class Pet
 {
  interface Iclimbtree
  {
   void climbtree();
  }
  interface Icatchmice
  {
   void catchmice();
  }
  public Pet(string name)
  {
   Name = name;
  }
  protected string Name;
  virtual public void printf()
  {
   Console.WriteLine(Name);

  }

    public class Dog:Pet,Icatchmice,Iclimbtree
  {
   
   public void catchmice()
   {
    Console.WriteLine(" " + Name + "catch");
   }
   public void climbtree()
   {
    Console.WriteLine(" " + Name + "tree");
   }
   public Dog(string name):base(name)
   {
    
   }
   override public void printf()
   {
    Console.WriteLine("mmm" + Name+"lll");

   }
  }
  public class Cat : Pet
  {
   public Cat(string name):base(name)
   {
    
   }
   override public void printf()
   {
    Console.WriteLine("mmm" + Name + "222");

   }
  }

 }
 class Program
 {
  static void Main(string[] args)
  {
   /*Pet dog1 = new Dog();
   dog1.Name = "eat";
   dog1.printf();
   Pet cat1 = new Cat();
   cat1.Name = "drink";
   cat1.printf();*/
   Pet[] pets = new Pet[] { new Dog("aaa"), new Cat("bbb") };
   for(int i=0;i<=pets.Length;i++)
   {
    pets[i].printf();
   }
   Cat cat1 = new Cat("Tom2");
   if(cat1 is Iclimbtree)
   {
    Iclimbtree cat = (Iclimbtree)cat1;
    cat.Iclimbtree();
   }
   


  }
 }


1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

老师源代码谁有吗?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信