I am currently working on a personal project in C++, and I'm having a lot of fun learning. I just learned some ideas on using inheritance and virtual functions. I decided to create a Budget Tracking console application! Of course, I could use control statements, and switches; however, I wanted to try and solve this using classes. Here is my code so far:
Main.cpp
#include
#include "MainMenu.h"
#include "Menu.h"
int main() {
std::cout << "Welcome to BudgetTracker!\n" <<
"Let's get started!\n\n";
Menu *menu = new MainMenu;
int mainInput;
menu->displayMenu();
std::cin >> mainInput;
menu->input(mainInput);
//Somehow switch my menu to a sub menu
//Add a loop without terminating entirely
}
MainMenu.cpp
#include "MainMenu.h"
MainMenu::MainMenu(){}
MainMenu::~MainMenu(){}
void MainMenu::displayMenu() {
std::cout << "Welcome to the MainMenu! \n" <<
"Select an option from the following: \n" <<
"1.....Overall View\n" <<
"2.....Accounts\n" <<
"3.....Spending\n" <<
"4.....Statistics\n" <<
"5.....Budgeting\n" <<
"0.....Close Program\n\n";
}
void MainMenu::input(int userInput) {
m_input = userInput;
std::cout << "You have entered " << m_input << ".\n\n";
//some code to enter a different submenu
}
In the end, I imagine a user entering, something along the lines of while in mainMenu -> input 2. Now in accountMenu -> input 3 to manage accounts. Input 2-> add account.
Can you guys help me find a way to implement this idea? I saw something in regards to a composite pattern design; however, I felt as though it doesn't match this idea. Am I wrong? Is this a wrong approach?
Thanks in advance!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)