I refactored my code and now it's only outputting 'You wrote x' when executed. Its also supposed to output a certain statement depending on the number entered into the terminal. I even made sure to compile everything again from scratch in case there were problems with the compilation.
I'm not sure what else to do. I would appreciate your help on this.
#include <iostream>
void printMenu()
{
// 1 print help
std::cout << "1: Print help" << std::endl;
// 2 print exchange stats
std::cout << "2: Print exchange stats" << std::endl;
// 3 make an offer
std::cout << "3: Make an offer" << std::endl;
// 4 make a bid
std::cout << "4: Make a bid" << std::endl;
// 5 print wallet
std::cout << "5: Print wallet" << std::endl;
// 6 continue
std::cout << "6: Continue" << std::endl;
std::cout << "==============" << std::endl;
}
int getUserOption()
{
int userOption;
std::cout << "Type in 1-6" << std::endl;
std::cin >> userOption;
std::cout << "You chose: " << userOption << std::endl;
return userOption;
}
void printHelp()
{
std::cout << "Help - your aim is to make money." << std::endl;
std::cout << "Analyse the market and make bids" << std::endl;
std::cout << "and offers. " << std::endl;
}
void printMarketStats()
{
std::cout << "Market looks good" << std::endl;
}
void enterAsk()
{
std::cout << "Make an offer. Enter the amount." << std::endl;
}
void enterBid()
{
std::cout << "Make a bid. Enter the amount." << std::endl;
}
void printWallet()
{
std::cout << "This is what's in your wallet:" << std::endl;
}
void gotoNextTimeframe()
{
std::cout << "Continue" << std::endl;
}
void processUserOption(int userOption)
{
if (userOption == 0 ) // bad input
{
std::cout << "Invalid choice. Choose 1-6" << std::endl;
}
if (userOption == 1)
{
printHelp;
}
if (userOption == 2)
{
printMarketStats;
}
if (userOption == 3)
{
enterAsk;
}
if (userOption == 4)
{
enterBid;
}
if (userOption == 5)
{
printWallet;
}
if (userOption == 6)
{
gotoNextTimeframe;
}
}
int main()
{
while (true)
{
printMenu();
int userOption = getUserOption();
processUserOption(userOption);
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire