Professional Documents
Culture Documents
Association Classes
Association Classes
Association Classes
Example 1: Consider the relationship "Person X owns N shares of Company Y". Where will N
be stored? N is neither an attribute of Company nor Person. In cases like this we can represent
links as objects. These link objects are instances of association classes:
During the implementation phase an association class might be translated into Java as follows:
public class Company { ... }
public class Person {
// etc.
}
class Owns {
private Person owner;
private Company company;
private int shares;
public Owns(Company c, Person p, int num) {
comnpany = c;
person = p;
shares = num;
}
// etc.
}
1
Example2
Buy
Customer Item
BuyItem