Project Submission (late)
Dependencies: mbed
Diff: Menus/Menus.h
- Revision:
- 3:83e79d31930c
- Parent:
- 0:72f372170a73
--- a/Menus/Menus.h Fri May 10 10:51:19 2019 +0000 +++ b/Menus/Menus.h Fri May 10 14:52:28 2019 +0000 @@ -5,22 +5,37 @@ #include <sstream> #include "N5110.h" -//#include "MenuGraphics.h" /* because these classes are so short and so closely linked, they are declared and defined in the same files for convenience and clarity */ -// abstract class for Button +/** Button Class + * @brief An abstract class for all button's in the program + * @brief The intent was to take advantage of polymorphism in C++ to cut out some large if-else blocks. + * @brief There are two functions to overload, run() is always overloaded. + * @brief runBack() is only overloaded for buttons attributed to increasing and decreasing variables, + * @brief for example buttons to modify the maze size or contrast/brightness. + * + * @brief Version 1.0 + * @author Thomas Caine + * @date May 2019 + */ class Button { public: int x; int y; + /** Button default constructor + */ Button() { x = y = 0; } + /** virtual run function for polymorphism + */ void virtual run() { printf("Button\n"); } + /** virtual runBack function for polymorphism + */ void virtual runBack() { printf("Back functionality\n"); // only overridden in functions that can be pressed backwards e.g. sliders @@ -28,7 +43,18 @@ } }; -// abstract class for Menu +/** Menu Class + * @brief An abstract class for all Menus's in the program + * @brief Takes advantage of polymorphism. Draw() function is overriden in every inheriting Menu class. + * @brief Score is used in the VictoryMenu and DefeatMenu classes. + * @details Due to the similarity of Menu classes and their small size, I did not give them all header and source files. + * @details Instead, classes are defined when they are declared in the same file and Buttons and Menus are grouped + * @details into the same header files based on common functionality. + * + * @brief Version 1.0 + * @author Thomas Caine + * @date May 2019 + */ class Menu { public: Button* buttons[3]; @@ -36,9 +62,14 @@ int numOfButtons; int buttonIndex; N5110* lcd; + /** Constructor for the Menu base class. + * @param lcd pointer - Passed to every menu object (derived classes super this constructor) so they can print to the lcd + */ Menu(N5110* screenPtr) : lcd(screenPtr) { numOfButtons = buttonIndex = 0; } + /** Virtual draw function, overloaded by Menus to print unique stuff. + */ void virtual draw() { printf("This is a menu\n"); }