Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
Loading...
Searching...
No Matches
names.cpp File Reference

Implementation of the stock name generation functions. More...

#include "names.h"
#include "random_price.h"
#include <algorithm>
Include dependency graph for names.cpp:

Go to the source code of this file.

Functions

vector< string > generate_name (unsigned int category, unsigned int num)
 Generates a set of unique stock names based on the specified category and quantity.
 
void pickUniqueNames (const unsigned int &num, const vector< string > &words, const vector< string > &suffixes, vector< string > &companyNames)
 Generates a vector of company names by combining words and suffixes.
 

Variables

string const category_list [category_list_size]
 List of stock categories.
 

Detailed Description

Implementation of the stock name generation functions.

Definition in file names.cpp.

Function Documentation

◆ generate_name()

vector< string > generate_name ( unsigned int category,
unsigned int num )

Generates a set of unique stock names based on the specified category and quantity.

Parameters
categoryThe category index [0 to category_list_size-1] indicating the stock category.
numThe number of stock names to generate.
Returns
A vector of unique stock names.
Note
There is a possibility of having an infinite loop if we called generate_names(0,99999999999999).

"Group 88" is the fallback value for input category out of [0, category_list_size - 1]

Definition at line 37 of file names.cpp.

37 {
38 // List of suffixes for stock names
39 vector<string> const suffixes = {"Holdings", "Ltd", "Group", "Corp", "Inc",
40 "Enterprises", "Solutions", "Services"};
41 vector<string> companyNames;
42
43 switch (category) {
44 case 0: { // Generate a name for Adv&Market category
45 vector<string> words = {"Alpha", "Beta", "Gamma", "Delta", "Epsilon",
46 "Innovate", "Solutions", "Strategies", "Impact", "Growth", "Creative",
47 "Digital", "Marketing", "Brand", "Communications", "Buzz", "Genius",
48 "Company", "Tech", "Global", "Dynamic", "Infinite", "Revolution",
49 "Evolution", "Power", "Innovation", "Inspire", "Transform", "Future",
50 "Vision", "Progress", "Solutions", "Excellence", "Advantage", "Success",
51 "Fortune", "Ventures", "Endeavor", "Pioneers", "Prosperity", "Synergy",
52 "Advertising", "Media", "Promotion", "Campaign", "Creative", "Strategy",
53 "Market", "Audience", "Brand", "Digital", "Social", "Influencer"};
54
55 pickUniqueNames(num, words, suffixes, companyNames);
56 break;
57 }
58 case 1: { // Generate a name for Aero&Def category
59 vector<string> words = {"Zeus", "Thor", "Hulk", "Loki", "Ironman",
60 "Captain", "America", "Valkyrie", "Odin", "Hawkeye", "Levi",
61 "Black Widow", "Vegeta", "Buu", "Sasuke", "Hephaestus", "Ares",
62 "Poseidon", "Apollo", "Hera", "Athena", "Artemis", "Hades", "Hercules",
63 "Mjolnir", "Stormbreaker", "Goku", "Shield", "Infinity", "Aizen",
64 "Panther", "Anya", "Yor", "Goalkeeper", "Itachi", "Web", "Ant", "Man",
65 "Groot", "Zhongli", "Lord", "Naruto", "Gojo", "Ichigo", "Kakashi",
66 "Saitama", "Witch", "Air", "Wings", "Flight", "Rocket", "Defender",
67 "Zeon", "Defense", "Airborne", "Aerospace", "Missile", "Anaheim",
68 "Supersonic", "Bomber", "Interceptor", "Pilot", "Sukuna", "Stealth",
69 "Warrior", "Aircraft", "Airman", "Seiya", "Sanji", "Airbase",
70 "Stratosphere", "Airshow", "Combat", "Zoro"};
71
72 pickUniqueNames(num, words, suffixes, companyNames);
73 break;
74 }
75 case 2: { // Generate a name for Airlines category
76 vector<string> words = {"Sky", "Wings", "Fly", "Jet", "Air", "Cloud",
77 "Aviation", "Aero", "Flight", "High", "Travel", "Skyward", "Lift",
78 "Airborne", "Airline", "Birds", "Wingman", "Up", "Glide", "Airbus",
79 "Propel", "Cmefly", "Airfield", "Skyline", "Airspeed", "Aircrew",
80 "Airshow", "Airspace", "Airway", "Aviator", "Airworthy", "Airstrip",
81 "Airman", "Airfare", "Airbag", "Airbus", "Airtime", "Takeoff",
82 "Landing", "Pilot", "Cabin", "Cockpit", "Airlift", "Airflow",
83 "Airliner", "Jetsetter", "Airship", "Airterminal", "Airsteward",
84 "Airstrike", "Airtaxi", "Airway"};
85
86 pickUniqueNames(num, words, suffixes, companyNames);
87 break;
88 }
89 case 3: { // Generate a name for RenewEnergy&storage category
90 vector<string> words = {"Solar", "Wind", "Eco", "Green", "Renew", "Sunny",
91 "Breezy", "Clean", "Efficient", "Power", "Sustainable", "Energize",
92 "Hydro", "Turbine", "Electric", "Sunshine", "Gust", "Nature", "Windy",
93 "Responsible", "Bio", "Geothermal", "Radiant", "Planet", "Emission",
94 "Sizzle", "Zap", "Wave", "Harvest", "Air", "Biomass", "Carbon",
95 "Efficiency", "Giga", "Innovate", "Mega", "Neutron", "Photon",
96 "Renewable", "Revolve", "Spark", "Thermal", "Vortex", "Watt", "Zero",
97 "PowerPunch", "JoltJester", "BatteryBanter", "EnergeticLaughs",
98 "StorageSpark", "ChargeChuckler", "HumorHavoc", "FunnyFuel",
99 "ZappyZingers", "WittyWatt", "EnergyVault", "PowerCell",
100 "StorageSolutions", "ChargeMaster", "BatteryTech", "PowerHub",
101 "EcoStorage", "RenewableEnergy", "EfficientEnergies", "EnergyVault",
102 "PowerCell", "StorageSolutions", "ChargeMaster", "BatteryTech",
103 "PowerHub", "EcoStorage", "RenewableEnergy", "EfficientEnergies"};
104
105 pickUniqueNames(num, words, suffixes, companyNames);
106 break;
107 }
108 case 4: { // Generate a name for Auto category
109 vector<string> words = {"Speed", "Drive", "Auto", "Wheel", "Car", "Turbo",
110 "Vroom", "Cruise", "Road", "Engine", "Flash", "Dom", "OnTheRoad",
111 "Lightning", "Muskla", "Sleek", "Gizmo", "Adrenaline", "Fuel", "Bumper",
112 "Sprint", "Beep", "Honk", "Mile", "Highway", "Chassis", "Rev", "Piston",
113 "Gear", "Accelerate", "Tyre", "Brake", "Transmission", "Steering",
114 "Ignition", "Convertible", "Stallion", "Cruiser", "Scooter", "Gadget",
115 "Horsepower", "Dashboard", "Gearshift", "Muscle", "Auto", "Toyopa",
116 "Honba", "Niisan", "Chevrolay", "Audio", "Mercidez", "BMX", "Lexxus",
117 "Subaro", "Kio", "Cadillax", "Mitsubi", "Folksvagen", "Porshee", "Jeep",
118 "Lambor", "Bentleey", "sherrari", "Rolling Roy", "Astton Lafite",
119 "Mazdah", "Volvo", "Infinitii", "Alfa Romeo", "Lexus", "Sloth",
120 "Land Hover", "Lincollin", "GMC", "Aubii", "Buddatti", "Maserahhi",
121 "McLaren", "Rage Rover"};
122
123 pickUniqueNames(num, words, suffixes, companyNames);
124 break;
125 }
126 case 5: { // Generate a name for Banks category
127 vector<string> words = {"Capital", "Trust", "Secure", "Savings", "Finest",
128 "Elite", "Prosper", "Advance", "Global", "Infinite", "Vault", "Wealth",
129 "First", "Premier", "Prime", "Harmony", "Velocity", "Pinnacle", "Noble",
130 "Fortune", "Evergreen", "Summit", "Frontier", "Excellence", "Sovereign",
131 "Centric", "Vantage", "Opus", "Paragon", "Zenith", "Crest", "Apex",
132 "Aegis", "Legacy", "Crown", "Krupt", "Meridian", "Encompass", "Equity",
133 "Stellar", "Eclipse"};
134
135 pickUniqueNames(num, words, suffixes, companyNames);
136 break;
137 }
138 case 6: { // Generate a name for Biotech category
139 vector<string> words = {"GeneWorks", "BioSolutions", "CellTech", "InnoGene",
140 "BioGenius", "VitaLab", "BioFusion", "GeneSynth", "EcoGene", "LifeTech",
141 "BioMedix", "GenoInnovate", "BioNova", "GeneQuest", "BioSpark",
142 "InnoCell", "BioRevolution", "GeneSense", "BioVital", "GeneXcel",
143 "BioMatrix", "GeneScribe", "InnoGene", "BioNexus", "GeneLink",
144 "BioTechne", "SynthoGene", "GeneWave", "BioGenome", "InnoBio",
145 "GenePrime", "BioSpectra", "InnoCell", "BioPlasma", "GeneTech",
146 "BioQuest", "GeneGenius", "InnoGene", "BioCure", "GeneCraft"};
147
148 pickUniqueNames(num, words, suffixes, companyNames);
149 break;
150 }
151 case 7: { // Generate a name for Broadcast category
152 vector<string> words = {"SoundBlast", "MediaMania", "EchoFiesta",
153 "ChannelChaos", "AudioCircus", "GlobalGiggles", "TalkTunes",
154 "Listen2Laughs", "WaveWhimsy", "LiveLaughs", "Listen2Me",
155 "StreamSmiles", "VoiceVortex", "RadioRuckus", "BroadcastBanter",
156 "SonicSilliness", "AudioAmusement", "MediaMirth", "TalkTickles",
157 "AudioWhoopee", "ListenUpLaughs", "StreamSilliness", "SoundPulse",
158 "ChannelChuckles", "RadioRoars", "VoiceVibe", "EchoEntertainment",
159 "AudioStreamers", "MediaLaughs", "TalkTrek", "WaveWire",
160 "BroadcastBliss", "SonicStreamers", "SoundSerendipity",
161 "AudioAmusement", "ListenInLaughs", "StreamCenter", "VoicePulse",
162 "RadioRadar", "ChannelWave", "SoundSync", "SoundWave", "MediaCast",
163 "EchoStream", "ChannelConnect", "AudioVision", "GlobalBroadcast",
164 "TalkTime", "Listen2me", "WaveLink", "LiveAudio", "StreamSquad",
165 "VoiceVortex", "RadioRevolution", "BroadcastHub", "SonicSignal",
166 "AudioSphere", "MediaMingle", "TalkBox", "AudioWave", "ListenUp",
167 "StreamStation", "SoundPulse", "ChannelChatter", "RadioRealm",
168 "VoiceVibe", "EchoChannel", "AudioStream", "MediaVox", "TalkTrek",
169 "WaveWire", "BroadcastBox", "SonicStream", "SoundSphere", "AudioMingle",
170 "ListenIn", "StreamCenter", "VoicePulse", "RadioRadar", "ChannelWave",
171 "SoundSync"};
172
173 pickUniqueNames(num, words, suffixes, companyNames);
174 break;
175 }
176 case 8: { // Generate a name for Casinos&Gaming category
177 vector<string> words = {"LuckyBets", "GameGalore", "SpinToWin",
178 "CasinoCraziness", "JackpotJamboree", "DiceyDelight", "GamblingGiggles",
179 "CardComedy", "WagerWhimsy", "WinningLaughs", "ChipsChuckles",
180 "PlayfulPoker", "SlotSilliness", "BingoBonanza", "RouletteRiot",
181 "CasinoComedy", "GamingGalore", "BetBloopers", "GamblingGalore",
182 "LaughingLottery", "SpinSmiles", "JokerJapes", "BlackjackBliss",
183 "GameGiggles", "LuckyLaughter", "Splash of Clans", "DiceDelirium",
184 "WagerWhoopee", "CardCapers", "WinningWhimsy", "ChipsChortle",
185 "GTB VII", "GTC V", "HunterXHunter", "PlayfulPoker", "SlotSilliness",
186 "BingoBanter", "RouletteRomp", "CasinoChuckles", "Monster Cooker World",
187 "GamingGalore", "BetBloopers", "GamblingGalore", "LaughingLottery",
188 "SpinSniggers", "Defence on Titan", "LuckyCasino", "GameCentral",
189 "SpinWin", "CasinoHub", "JackpotCity", "Denshin Impact",
190 "Splash Royale", "DiceGaming", "GamblingClub", "CardMaster",
191 "WagerZone", "WinningStreak", "Road Fighter XI", "ChipsPalace",
192 "PlayfulGaming", "SlotParadise", "BingoEmpire", "RouletteRealm",
193 "Sudoku", "CasinoWorld", "GamingZone", "BetMasters", "GamblingKingdom",
194 "LuckyLottery", "Cooking Papa", "SpinPalace", "JokerCasino",
195 "BlackjackElite", "GameMaster", "LuckyWin", "ForNight", "WeCraft",
196 "DiceGaming", "WagerZone", "CardMaster", "WinningStreak", "ChipsPalace",
197 "Hokemon", "PlayfulGaming", "SlotParadise", "BingoEmpire",
198 "RouletteRealm", "CasinoWorld", "MustLose", "GuaranteedWin",
199 "GamingZone", "BetMasters", "GamblingKingdom", "LuckyLottery",
200 "SpinPalace", "Nario"};
201
202 pickUniqueNames(num, words, suffixes, companyNames);
203 break;
204 }
205 case 9: { // Generate a name for E-Commerce category
206 vector<string> words = {"Shopaholic", "Buy-o-matic", "DealDiva",
207 "CartoonCraze", "SaleSensation", "Hundredcents", "Thousandcents",
208 "DiscountDelight", "BargainBonanza", "OnlineOlympics", "ShipShop",
209 "PricelessPurchases", "SkyDog", "Bmazon", "ClickComedy", "eBayLaughs",
210 "AmazonAmusement", "ShoppingShenanigans", "VirtualVortex",
211 "SaleSlapstick", "Buyer'sBliss", "DealDazzle", "CartoonCapers",
212 "ShopSmart", "SkyCat", "BuyDirect", "DealFinder", "CartConnect",
213 "SaleSpot", "DiscountMart", "BargainHunt", "OnlinePlaza", "ShipRight",
214 "PricePoint", "ClickCentral", "eBayDeals", "AmazonEmporium",
215 "ShoppingSolutions", "VirtualMarket", "SaleSolutions",
216 "Buyer'sParadise", "DealHaven", "CartConnect"};
217
218 pickUniqueNames(num, words, suffixes, companyNames);
219 break;
220 }
221 case 10: { // Generate a name for FinServices category
222 vector<string> words = {"CashComedy", "Dollar Dazzle", "FinanceFunnies",
223 "WealthWhimsy", "MoneyMaster", "InvestmentLaughs", "Savings Smiles",
224 "FunnyFunds", "PennyPunchlines", "BillsBanter", "CapitalConsulting",
225 "WealthManagement", "FinancialSolutions", "MoneyMatters",
226 "InvestmentAdvisors", "SecureBanking", "SmartFunds",
227 "EconomicConsultancy", "FinancialExperts"};
228
229 pickUniqueNames(num, words, suffixes, companyNames);
230 break;
231 }
232 case 11: { // Generate a name for Food&Beverage category
233 vector<string> words = {"Tasty", "Delicious", "Yummy", "Flavorful",
234 "Gourmet", "Savor", "Flavors", "Satisfy", "Cuisine", "Culinary",
235 "Taste", "Palate", "Savoring", "Bites", "Mouthwatering", "Bakery",
236 "Cafe", "Catering", "Dining", "Juicy", "Zesty", "Fresh", "Spice", "Sip",
237 "Brew", "Crave", "Snack", "Seasoned", "Saucy", "Wholesome", "Nourish",
238 "Treats", "Feast", "Chew", "Munch", "Appetite", "Sip", "Gobble", "Gulp",
239 "Plate", "Yum", "Morsel", "Nibble", "Digest", "Mouthful", "Bistro",
240 "Savor", "Crunch", "Sizzle", "Devour"};
241
242 pickUniqueNames(num, words, suffixes, companyNames);
243 break;
244 }
245 case 12: { // Generate a name for Healthcare&Pharm category
246 vector<string> words = {"Health", "Wellness", "Care", "Medical", "Life",
247 "Apple/Day", "Vital", "Active", "Healthy", "Cure", "Recover", "Pay4Med",
248 "Nourish", "Thrive", "Restore", "Revive", "Fit", "Strong", "Balance",
249 "Medi", "Pharma", "Sana", "Sano", "Salute", "Pulse", "Vita",
250 "Healthcare", "Wellbeing", "Medic", "Clinic", "Well", "Doctor", "Nurse",
251 "Heal", "Surgery", "Wellness", "Rx", "Pharm", "Lab", "Medical",
252 "Caring", "Healing", "Rehab", "Recovery", "Dose", "MediCare", "Medix",
253 "Pharma", "Pharmaceutical", "Medi", "Health", "Care", "Wellness", "Rx",
254 "Med", "Vita", "Sana", "Sano", "Salute", "Pulse", "Pharmacy",
255 "Medicine", "Drugs", "Wellbeing", "Cure", "Heal", "Remedy", "Prescribe",
256 "Relief", "Recovery", "Dose", "MediCare", "Medix", "Healthy", "Fit",
257 "Strong", "Balance"};
258
259 pickUniqueNames(num, words, suffixes, companyNames);
260 break;
261 }
262 case 13: { // Generate a name for Tech category
263 vector<string> words = {"Tech", "Digital", "Innovate", "Byte", "Code",
264 "Data", "Logic", "Connect", "Smart", "Cyber", "Net", "Cloud", "Web",
265 "Nerd", "Geek", "Infinite", "System", "Guru", "Genius", "Solve",
266 "Pixel", "Bit", "Invent", "KKGarden"};
267
268 pickUniqueNames(num, words, suffixes, companyNames);
269 break;
270 }
271 case 14: { // Generate a name for RealEstate category
272 vector<string> words = {"Real", "Estate", "Property", "Homes", "Realty",
273 "Invest", "Buy", "Sell", "House", "Land", "Residential", "Commercial",
274 "Development", "Build", "Investment", "Acres", "Estates", "Brokers",
275 "Agents", "Mortgage", "Rent", "Lease", "Property", "Assets", "Housing",
276 "Tower", "Plaza", "Villa", "Condo", "Develop", "Society", "Park",
277 "Living", "Urban", "Suburban"};
278
279 pickUniqueNames(num, words, suffixes, companyNames);
280 break;
281 }
282 case 15: { // Generate a name for Retail category
283 vector<string> words = {"Obsidian", "Velvetine", "Stellar", "Luminary",
284 "Nebula", "Zephyr", "Elixir", "Intrigue", "Sapphire", "Crimson",
285 "Aurora", "Celestial", "Enigma", "Mystique", "Euphoria", "Radiance",
286 "Galaxy", "Harmonia", "Opulence", "Ethereal", "Curio", "Boutique",
287 "Ethereal", "Nook", "Vivid", "Enchant", "Whimsy", "Delight",
288 "Serendipity", "Wander", "Charm", "Spruce", "Eclectic", "Rustic",
289 "Vintage"};
290
291 pickUniqueNames(num, words, suffixes, companyNames);
292 break;
293 }
294 case 16: { // Generate a name for Telecom category
295 vector<string> words = {"Connect", "Link", "Wireless", "Tele", "Net",
296 "Signal", "Comm", "Telecom", "Tech", "Mobile", "Global", "Data", "Wave",
297 "Teleconnect", "Swift", "Talk", "Voice", "Fiber", "Reach", "OnCall",
298 "Echo", "Pulse", "Synapse", "Velocity", "Empower", "Amplify",
299 "Momentum", "Infinite", "Nexus", "Stream", "Sync", "Telepath",
300 "Radiant", "Blaze", "Quantum"};
301
302 pickUniqueNames(num, words, suffixes, companyNames);
303 break;
304 }
305 default:
306 /** "Group 88" is the fallback value for input category out of [0,
307 * category_list_size - 1] */
308 return std::vector<std::string>(1, "Group 88");
309 break;
310 }
311 return companyNames;
312}
@ category
This event will apply to stocks within the specified category.
Definition events.h:92
void pickUniqueNames(const unsigned int &num, const vector< string > &words, const vector< string > &suffixes, vector< string > &companyNames)
Generates a vector of company names by combining words and suffixes.
Definition names.cpp:314

References category, and pickUniqueNames().

Referenced by Stock::Stock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pickUniqueNames()

void pickUniqueNames ( const unsigned int & num,
const std::vector< std::string > & words,
const std::vector< std::string > & suffixes,
std::vector< std::string > & companyNames )

Generates a vector of company names by combining words and suffixes.

Parameters
numThe number of company names to generate.
wordsA vector of words to use in the company names.
suffixesA vector of suffixes to use in the company names.
companyNamesThe vector of company names to generate. This vector will be modified by the function.
Todo
: add a test case or assertion
Todo
Todo
: use unordered_set instead of vector since we are checking for uniqueness

Definition at line 314 of file names.cpp.

315 {
316 /// @todo: add a test case or assertion
317 /// @todo: use unordered_set instead of vector since we are checking for uniqueness
318 decltype(num) pickedNamesAmount = num;
319 while (companyNames.size() < pickedNamesAmount) {
320 string name = words[random_integer(words.size())] + " " +
321 suffixes[random_integer(suffixes.size())];
322 const bool companyNameAlreadyPresent =
323 find(companyNames.begin(), companyNames.end(), name) == companyNames.end();
324 if (companyNameAlreadyPresent) {
325 companyNames.emplace_back(name);
326 }
327 }
328}
unsigned int random_integer(unsigned int max_integer)
python randint like function

References random_integer().

Referenced by generate_name().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ category_list

string const category_list[category_list_size]
Initial value:
= {"Adv&Market", "Aero&Def", "Airlines",
"RenewEnergy", "Auto", "Banks", "Biotech", "Broadcast", "Casinos&Gaming",
"E-Commerce", "FinServices", "Food&Beverage", "Healthcare", "Tech", "RealEstate",
"Retail", "Telecom"}

List of stock categories.

The array category_list is declared as extern since it will be defined in names.cpp. It is not defined in names.h to avoid multiple definition errors, and to follow good programming practices.

Definition at line 22 of file names.cpp.

22 {"Adv&Market", "Aero&Def", "Airlines",
23 "RenewEnergy", "Auto", "Banks", "Biotech", "Broadcast", "Casinos&Gaming",
24 "E-Commerce", "FinServices", "Food&Beverage", "Healthcare", "Tech", "RealEstate",
25 "Retail", "Telecom"};

Referenced by Stock::category_name().