Project Submission (late)

Dependencies:   mbed

Committer:
el17tc
Date:
Fri May 10 14:52:28 2019 +0000
Revision:
3:83e79d31930c
Parent:
0:72f372170a73
final commit, API is added.; I'm not sure if there is a specific statement of academic integrity wanted but- I declare that this work is 100% my own, I have not plagiarised any work or attempted to fabricate any part of it for extra marks.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17tc 0:72f372170a73 1 #ifndef VICTORYMENU_H
el17tc 0:72f372170a73 2 #define VICTORYMENU_H
el17tc 0:72f372170a73 3
el17tc 0:72f372170a73 4 #include "Menus.h"
el17tc 0:72f372170a73 5
el17tc 0:72f372170a73 6 // yes button used in the VictoryMenu and the DefeatMenu
el17tc 3:83e79d31930c 7 /** YesButton Class
el17tc 3:83e79d31930c 8 * @brief Derived from Button. Used in VictoryMenu and DefeatMenu.
el17tc 3:83e79d31930c 9 * @brief Sends user to the StartMenu.
el17tc 3:83e79d31930c 10 */
el17tc 0:72f372170a73 11 class YesButton : public Button {
el17tc 0:72f372170a73 12 public:
el17tc 0:72f372170a73 13 YesButton() {
el17tc 0:72f372170a73 14 x = 5;
el17tc 0:72f372170a73 15 y = 32;
el17tc 0:72f372170a73 16 }
el17tc 0:72f372170a73 17 void virtual run() {
el17tc 0:72f372170a73 18 printf("YesButton pushed\n");
el17tc 0:72f372170a73 19 restartFlag = true;
el17tc 0:72f372170a73 20 }
el17tc 0:72f372170a73 21 };
el17tc 0:72f372170a73 22 // no button used in the VictoryMenu and the DefeatMenu
el17tc 3:83e79d31930c 23 /** NoButton Class
el17tc 3:83e79d31930c 24 * @brief Derived from Button. Used in VictoryMenu and DefeatMenu.
el17tc 3:83e79d31930c 25 * @brief Sends user to the MainMenu.
el17tc 3:83e79d31930c 26 */
el17tc 0:72f372170a73 27 class NoButton : public Button {
el17tc 0:72f372170a73 28 public:
el17tc 0:72f372170a73 29 NoButton() {
el17tc 0:72f372170a73 30 x = 58;
el17tc 0:72f372170a73 31 y = 32;
el17tc 0:72f372170a73 32 }
el17tc 0:72f372170a73 33 void virtual run() {
el17tc 0:72f372170a73 34 printf("NoButton pushed\n");
el17tc 0:72f372170a73 35 menuFlag = true;
el17tc 0:72f372170a73 36 }
el17tc 0:72f372170a73 37 };
el17tc 0:72f372170a73 38 // VictoryMenu displays when the player escapes the maze, it displays score
el17tc 0:72f372170a73 39 // and restart options
el17tc 3:83e79d31930c 40 /** VictoryMenu Class
el17tc 3:83e79d31930c 41 * @brief Derived from Menu. Displayed when the maze is escaped.
el17tc 3:83e79d31930c 42 * @brief Or more accurately when the winFlag = true.
el17tc 3:83e79d31930c 43 */
el17tc 0:72f372170a73 44 class VictoryMenu : public Menu {
el17tc 0:72f372170a73 45 public:
el17tc 0:72f372170a73 46 VictoryMenu(N5110* screenPtr) : Menu(screenPtr) {
el17tc 0:72f372170a73 47 buttons[0] = new YesButton;
el17tc 0:72f372170a73 48 buttons[1] = new NoButton;
el17tc 0:72f372170a73 49 currentButton = buttons[0];
el17tc 0:72f372170a73 50 numOfButtons = 2;
el17tc 0:72f372170a73 51 buttonIndex = 0;
el17tc 0:72f372170a73 52 }
el17tc 0:72f372170a73 53 void virtual draw() {
el17tc 0:72f372170a73 54 std::stringstream sscore;
el17tc 0:72f372170a73 55 sscore << "Score: " << score;
el17tc 0:72f372170a73 56 lcd->printString("VICTORY",10,1);
el17tc 0:72f372170a73 57 lcd->printString(sscore.str().c_str(),10,2);
el17tc 0:72f372170a73 58 lcd->printString("Play again?",10,3);
el17tc 0:72f372170a73 59 lcd->printString("Yes No",10,4);
el17tc 0:72f372170a73 60 }
el17tc 3:83e79d31930c 61 /** Destructor
el17tc 3:83e79d31930c 62 */
el17tc 0:72f372170a73 63 ~VictoryMenu() {
el17tc 0:72f372170a73 64 delete buttons[0];
el17tc 0:72f372170a73 65 delete buttons[1];
el17tc 0:72f372170a73 66 }
el17tc 0:72f372170a73 67 };
el17tc 0:72f372170a73 68
el17tc 0:72f372170a73 69 #endif // VICTORYMENU_H