类的六种关系(按关系由弱到强排列):
依赖关系(Dependency)<关联关系(Association)<聚合关系(Aggregation)<组合关系(Composition)<泛化关系(Generalization)==实现关系(realization)
1,<依赖关系(Dependency)>
依赖关系可解析为A类使用了B类,此处则以Person使用Computer为例子
那么依赖的四种形式为:
(1)参数传递
public class Person
{
//以参数形式/返回值依赖起来
public Computer Programing(Computer toy)
{
return null;
}
}
(2)作为类中的局部对象
public class Person
{
//在函数中以局部变量的形式出现
public void Person()
{
Toy tToy = new Toy();
}
}
(3)调用Computer静态方法
public class Computer
{
static public void Open(){}
}
public class Person
{
public void Programing(