Association Classes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

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

You might also like