When working on larger projects, you will need to carefully plan ahead the structure of your applications/programs. You will have to break down your application into smaller modules and will most likely want to give your end-users the option to navigate through all these sub-modules.
This top-down/modular approach to designing and structuring your applications will enable you to break down what may seem like a very complex project into smaller, achievable modules that you will complete progressively one at a time.
In order for your end-user to access to all the modules available you may be willing to offer a menu structure. This could use drop down menu bars, touch screen icons/menus or a text-based menu system used with a command prompt to interact with the end-user.
In this challenge we will focus on this latest approach: a text-based menu system with a command prompt to retrieve user inputs/choices. Note that the logic behind this would be similar with other types of menus based on a Graphical User Interface or touchscreen or even with a voice activated interface.
We are about to create our first video game and have produced the following top/down modular design for it.
Let’s look at how this would look like once implemented using Python:
This option is a bit more complex and enables the end-user to navigate between menus and sub-menus.
This code is exactly the same as the code used for option #2. However by splitting the code into mutilple .py files it looks neater and easier to maintain.
When using a modular approach to breaking down a large project we often spread the code accross multiple files. It makes troubleshooting a lot easier.
There are many ways we could improve this menu system such as: