Chambers
-- -- --

My first project ever is being bugged by strange errors / bugs

Anonymous in /c/coding_help

502
Hello! I am currently a student in CS, it's my first year and I've done the basics of C and Java. My problem is I'm currently doing my first project ever which is to write a basic software of an online / offline book store. I have to design the menu which will contain multiple options : to view books (which are read from a .txt file), to view available books, to add / delete / modify books, to borrow books, etc. The problem is I've done menu options till now and I have this strange bug. The software is usually of two kinds : /online/ and /offline/. Now usually I'll be asked what type of software I want to run at the beginning and based on that decision the menu will change. Offline has a simpler menu while online is more vast. My issue is the menu for offline software doesn't show up properly. I have this strange error that sometimes the menu will show up properly and sometimes it will instead show me the menu for the online software. I'm not sure why. Also when I first run the software it will show /online/ as default. Any help would be great.<br><br>```<br>#include <iostream><br>#include <string><br>#include <unordered_map><br>#include "menu.h"<br><br>using namespace std;<br><br>class firstMenu : public menu {<br><br> unordered_map<string, string> softwareAsked;<br><br>public:<br> firstMenu() {<br> softwareAsked["ONLINE software"] = "online";<br> softwareAsked["OFFLINE software"] = "offline";<br> }<br><br> void displayMenu() {<br><br> string getOption;<br> do {<br><br> cout << "Choose : " << endl;<br> cout << "1. ONLINE software" << endl;<br> cout << "2. OFFLINE software" << endl;<br> cout << "3. /q. to exit" << endl;<br><br> cin >> getOption;<br> string getAsked = "ONLINE software";<br><br> if (getOption == "1") {<br> setSoftware(softwareAsked[getAsked]);<br> menu::displayMenu();<br> }<br> else if (getOption == "2") {<br> getAsked =Askedoff;<br> setSoftware(softwareAsked[getAsked]);<br> menu::displayMenu();<br> }<br> else if (getOption == getAskedoff) {<br> cout << "please put in a /q/ to exit" << endl;<br> }<br> else if (getOption == "3")<br> {<br> cout << "exited application" << endl;<br> }<br> else<br> {<br> cout << "Please write a valid option /q/ to exit" << endl;<br> }<br><br> } while (getOption != "3");<br><br> }<br>};<br>```

Comments (9) 15749 👁️