Yes. The abstract Card
class can be used as a model of what each
new type of card should look like.
By using hierarchical organization and inheritance it is easy to add many more card classes and to create a well organized program. This was unthinkable not too many years ago. Here is a sample run of this program:
Your name: Sue Dear Sue, Season's Greetings! Dear Sue, Happy 21th Birthday Dear Sue, Love and Kisses, XXXXXXX
When the main()
method has constructed its
three objects, the situation is as in the picture.
There are three classes that can be instantiated,
and one object of each class has been instantiated.
Of course,
as many objects as you need of each type (except Card
)
can be instantiated.
There are 4 classes. Why can only 3 be instantiated?