Association - Aggregation

Aggregation is where an object has a reference to another object. That object though may exist separately from the related object.
For example a football team may contain a player, but that player could move to another team.
When an object which contains other objects is destroyed, the other objects will still exist.

Challenge

A Deck of cards is a collection of cards. Those cards can exist separate from the Deck, for example they may be in a players’ hands or on the table.

The relationship between the cards is association aggregation.

It can be said that the deck has a card.

Create an implementation of the above class diagram.
You may need to create a public constructor for each class.
It is OK to create private methods (this is the point of encapsulation; hiding implementation details).

Once you have created the classes, get your program to:

  • Deal 7 cards and display them on the screen.

  • Cut the deck, then deal 7 more cards on the screen.

  • Shuffle the deck, then deal a further 7 cards on the screen.