|
Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
|
Header files for file operation functions related to the game. More...
#include "stock.h"

Go to the source code of this file.
Classes | |
| class | USER_SAVE_OPTION |
| The user save options. More... | |
Functions | |
| bool | checkValidInput (const std::string &input) |
| Check if the input is valid. | |
| void | createplayer (std::string &playerName) |
| Create a player folder. | |
| void | delsave (std::string &mode) |
| Delete a save. | |
| std::vector< std::string > | get_saves (void) |
| Get the list of saves aka player folders. | |
| void | loadstatus (unsigned int &rounds_played, std::vector< Stock > &stocks_list, float &balance, std::string &playerName, std::vector< float > &hsi_history) |
| Load an existing game status from .save files. | |
| std::vector< std::string > | parseLogo (void) |
| returns the game logo, which is hardcoded inside the function. | |
| void | printvector (const std::vector< std::string > &avector) |
| Print the vector of saves aka player folders. | |
| void | savestatus (unsigned int rounds_played, std::vector< Stock > stocks_list, float balance, const std::string &playerName) |
| Save the game status into *.save files. | |
Variables | |
| const std::string | SAVE_FILE_EXTENSION_TXT = ".save" |
| const std::string | SAVE_FOLDER_PREFIX = "saves/" |
| const std::string | USER_SAVE_OPTION_PROMPT |
Header files for file operation functions related to the game.
Definition in file file_io.h.
|
inline |
Check if the input is valid.
The input is valid if it is one of the options in the USER_SAVE_OPTION class.
| input | The input string |
Definition at line 37 of file file_io.h.
References USER_SAVE_OPTION::DELETE_GAME, USER_SAVE_OPTION::EXIT_GAME, USER_SAVE_OPTION::LOAD_GAME, and USER_SAVE_OPTION::NEW_GAME.
Referenced by initializePlayerSaves().

| void createplayer | ( | std::string & | playerName | ) |
Create a player folder.
| playerName | Pass the playerName by reference. |
Definition at line 69 of file file_io.cpp.
References playerName, and SAVE_FOLDER_PREFIX.
Referenced by initializePlayerSaves(), and loadstatus().

| void delsave | ( | std::string & | mode | ) |
Delete a save.
| mode | Return the mode choice (0,1,2,3) by reference for further control after deleting |
Definition at line 158 of file file_io.cpp.
References USER_SAVE_OPTION::EXIT_GAME, get_saves(), USER_SAVE_OPTION::NEW_GAME, printvector(), and SAVE_FOLDER_PREFIX.
Referenced by initializePlayerSaves().


| std::vector< std::string > get_saves | ( | void | ) |
Get the list of saves aka player folders.
Definition at line 214 of file file_io.cpp.
References SAVE_FOLDER_PREFIX.
Referenced by delsave(), and loadstatus().

| void loadstatus | ( | unsigned int & | rounds_played, |
| std::vector< Stock > & | stocks_list, | ||
| float & | balance, | ||
| std::string & | playerName, | ||
| std::vector< float > & | hsi_history ) |
Load an existing game status from .save files.
Paramenters should be empty and values are returned by reference.
| rounds_played | The number of rounds played |
| stocks_list | A vector of stocks |
| balance | The balance of the player |
| playerName | The name of the player also the folder name |
| hsi_history | A vector of HSI history |
Definition at line 120 of file file_io.cpp.
References balance, createplayer(), get_saves(), initial_stock_count, load_hsi(), playerName, printvector(), rounds_played, SAVE_FILE_EXTENSION_TXT, and SAVE_FOLDER_PREFIX.
Referenced by initializePlayerSaves().


| std::vector< std::string > parseLogo | ( | void | ) |
returns the game logo, which is hardcoded inside the function.
Definition at line 34 of file file_io.cpp.
Referenced by drawLogo().

| void printvector | ( | const std::vector< std::string > & | avector | ) |
Print the vector of saves aka player folders.
Definition at line 222 of file file_io.cpp.
Referenced by delsave(), and loadstatus().

| void savestatus | ( | unsigned int | rounds_played, |
| std::vector< Stock > | stocks_list, | ||
| float | balance, | ||
| const std::string & | playerName ) |
Save the game status into *.save files.
| rounds_played | The number of rounds played |
| stocks_list | A vector of stocks |
| balance | The balance of the player |
| playerName | The name of the player also the folder name |
Definition at line 104 of file file_io.cpp.
References balance, playerName, rounds_played, SAVE_FILE_EXTENSION_TXT, and SAVE_FOLDER_PREFIX.
Referenced by initializePlayerSaves(), and main().

| const std::string SAVE_FILE_EXTENSION_TXT = ".save" |
Definition at line 48 of file file_io.h.
Referenced by get_hsi(), graphinput(), Stock::load(), load_hsi(), loadstatus(), Stock::save(), and savestatus().
| const std::string SAVE_FOLDER_PREFIX = "saves/" |
Definition at line 45 of file file_io.h.
Referenced by createplayer(), delsave(), get_hsi(), get_saves(), graphinput(), Stock::load(), load_hsi(), loadstatus(), Stock::save(), and savestatus().
|
extern |
Definition at line 28 of file file_io.cpp.
Referenced by initializePlayerSaves().