Java Reference
In-Depth Information
Once we have defined the MessagePost and PhotoPost classes, we can create as many post ob-
jects as we need—one object per message post or photo post that we want to store. Apart from this,
we then need another object: an object representing the complete news feed that can hold a collection
of message posts and a collection of photo posts. For this, we shall create a class called NewsFeed .
The NewsFeed object could itself hold two collection objects (for example, of types ArrayList
<MessagePost> and ArrayList<PhotoPost> ). One of these collections can then hold all message
posts, the other all photo posts. An object diagram for this model is shown in Figure 8.3.
Figure 8.3
Objects in the net-
work application
The corresponding class diagram, as BlueJ displays it, is shown in Figure 8.4. Note that BlueJ
shows a slightly simplified diagram: classes from the standard Java library ( ArrayList in this
case) are not shown. Instead, the diagram focuses on user-defined classes. Also, BlueJ does not
show field and method names in the diagram.
Figure 8.4
BlueJ class diagram
of network
 
Search WWH ::




Custom Search