O'Reilly logo

Learning D by Michael Parker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required