Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
|
Implementation of the file input/output functions. More...
#include "file_io.h"
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <iostream>
Go to the source code of this file.
Functions | |
void | createplayer (string &playerName) |
Create a player folder. | |
void | delsave (string &mode) |
Delete a save. | |
vector< string > | get_saves (void) |
Get the list of saves aka player folders. | |
void | load_hsi (std::vector< float > &hsi_history, const string &playerName) |
void | loadstatus (unsigned int &rounds_played, vector< Stock > &stocks_list, float &balance, string &playerName, vector< float > &hsi_history) |
Load an existing game status from .save files. | |
vector< string > | parseLogo (void) |
returns the game logo, which is hardcoded inside the function. | |
void | printvector (const vector< string > &avector) |
Print the vector of saves aka player folders. | |
void | savestatus (unsigned int rounds_played, vector< Stock > stocks_list, float balance, const string &playerName) |
Save the game status into *.save files. | |
Variables | |
const std::string | USER_SAVE_OPTION_PROMPT |
Implementation of the file input/output functions.
Definition in file file_io.cpp.
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().
vector< 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 load_hsi | ( | std::vector< float > & | hsi_history, |
const string & | playerName ) |
Definition at line 92 of file file_io.cpp.
References playerName, SAVE_FILE_EXTENSION_TXT, and SAVE_FOLDER_PREFIX.
Referenced by 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().
vector< 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 vector< 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 USER_SAVE_OPTION_PROMPT |
Definition at line 28 of file file_io.cpp.
Referenced by initializePlayerSaves().