MovieMan – adding menus
It's time now to take some of the features covered in this chapter and apply them to MovieMan
. The code listings here will, unfortunately, be incomplete in the interests of keeping the page count down. However, the complete implementation can be found in the Chapter03/MovieMan
directory of the downloadable source code.
The MovieMan
menus are implemented as a small set of classes: Menu
, MainMenu
, and DisplayMenu
. We could debate composition versus inheritance, or the use of classes to implement such simple menus, but my priority is to provide a demonstration of D features.
The Menu base class
To get started, save a file called $MOVIEMAN/source/movieman/menu/menu.d
. At the very top, add the following lines:
module movieman.menu.menu; ...
Get Learning D now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.