jisi

导航

C#

using System;

using System.Collections.Generic;

using System.Linq; using System.Text;

namespace Ex_4_4

   {    

           public class Organism      

   {

            public string name;        

         public int age;          

         public   Organism()         

    {                              

  age = 1;     

        }         

    public Organism(string name,int age)      

       {

                this.name = name;           

      this.age = age;

            }         

    public void Display()         

    {             

    Console.WriteLine("My name is {0}", this.name);             

    Console.WriteLine("I am {0} years old", this.age);       

      }           

  ~Organism()         

    {            

}       

  }      

   public class Animals : Organism    

     {           

  private int Height, Weight;    

         string Sex;

            public Animals(string name, int age) : base(string name,int age) { }     

        public Animals(int Height, int Weight,string Sex)    

         {                                              

   this.Height = Height;         

        this.Weight = Weight;               

  this.Sex = Sex;                     

    }

            public void Move()          

   {                

Console.WriteLine("I can move");      

       }        

    public void Mydisplay()            

{                               

Console.WriteLine("My height is {0};\r\nMy weight is {1}\r\nI am a {2} ",this.Height,this.Weight,this.Sex);     

        }

        }        

public class Botany : Organism     

    {            

private int cycle;                

        public Botany(int year)         

    {                

cycle = year;           

  }                        

public void Grow()          

   {             

    Console.WriteLine("I can grow up");

            }     

    }

           }

posted on 2012-04-29 11:07  jisikeji  阅读(125)  评论(0编辑  收藏  举报