1.继承:

 

 Animal
        {
        }
        public class Bird:Animal
        {
        }

2.关联关系

 


        public class Climate
        {
        }
        
public class Penguin : Bird
        {
            
private Climate climate;//在企鹅Penguin中,引用到气候Climate对象
        }
        
#endregion

3.聚合关系

 


        //大雁
        public class WideGoose
        {
        }
        
public class WideGooseAggregate
        {
            
private WideGoose[] arrayWideGoose;//在雁群WideGooseAggregate类中,有大雁数组对象arrayWideGoose
        }
        
#endregion

4.组合关系

 


        public class Duck:Bird
        {
            
private Wing wing;
            
public Duck()
            {
                
//在Duck类中,初始化时,实例化翅膀Wing,他们之间同时生成
                wing = new Wing();
            }
        }
        
public class Wing
        {
        }
        
#endregion

5.依赖关系

 


        public class Water
        {
        }
        
public class People
        {
            
//人依赖于水
            public People(Water water)
            {
            }
        }
        
#endregion

相关文章:

  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2021-12-09
  • 2022-02-08
  • 2021-12-27
相关资源
相似解决方案