class Artist{
List<Guitar> guitars;
public Artist(){
}
public AddGuitarToCollection(Guitar newGuitar){
Guitars.Add(newGuitar);
}
}
So, that's how we accomplish this in code (most of the time!). You won't usually need different types of lines and arrows if you are new to programming. Keep it simple.
Dependency is a weaker form of bond which indicates that one class depends on
another because it uses it at some point in time. One class depends on
another if the independent class is a parameter variable or local variable of
a method of the dependent class. This is different from an association, where
an attribute of the dependent class is an instance of the independent class.
Sometimes the relationship between two classes is very weak. They are not
implemented with member variables at all. Rather they might be implemented as
member function arguments.
如果有一个连接、关系、关联等需要存在,那么到 class A 就可以工作; 它是一个依赖项。例句: 丈夫 需求妻子的存在。一辆汽车 需求一个轮子是一辆汽车(和驾驶)。一个汽车工厂 需求一个汽车类,使一个对象从它。您的 RSSNewsItem 类 需求和 XMLReader 类可以执行任何操作。