1.继承:
public class Animal
{
}
public class Bird:Animal
{
}
2.关联关系
#region 关联关系,表明企鹅类知道气候
public class Climate
{
}
public class Penguin : Bird
{
private Climate climate;//在企鹅Penguin中,引用到气候Climate对象
}
#endregion
3.聚合关系
#region 聚合关系,表示一种弱的拥有关系
//大雁
public class WideGoose
{
}
public class WideGooseAggregate
{
private WideGoose[] arrayWideGoose;//在雁群WideGooseAggregate类中,有大雁数组对象arrayWideGoose
}
#endregion
4.组合关系
#region 组合关系,表示一种强的拥有关系
public class Duck:Bird
{
private Wing wing;
public Duck()
{
//在Duck类中,初始化时,实例化翅膀Wing,他们之间同时生成
wing = new Wing();
}
}
public class Wing
{
}
#endregion
5.依赖关系
#region 依赖关系
public class Water
{
}
public class People
{
//人依赖于水
public People(Water water)
{
}
}
#endregion