Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Video Game #586

Merged
merged 13 commits into from
May 25, 2024
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set(FAKER_SOURCES
src/modules/system/System.cpp
src/modules/vehicle/Vehicle.cpp
src/modules/videoGame/VideoGame.cpp
src/modules/videoGame/VideoGameData.cpp
src/modules/weather/Weather.cpp
src/modules/word/Word.cpp
src/common/FormatHelper.cpp
Expand Down
10 changes: 5 additions & 5 deletions include/faker-cxx/VideoGame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string>
#include <string_view>

namespace faker
{
Expand All @@ -16,7 +16,7 @@ class VideoGame
* VideoGame::gameTitle() // "Rayman Arena"
* @endcode
*/
static std::string gameTitle();
static std::string_view gameTitle();

/**
* @brief Returns a random video game genre.
Expand All @@ -27,7 +27,7 @@ class VideoGame
* VideoGame::genre() // "Platformer"
* @endcode
*/
static std::string genre();
static std::string_view genre();

/**
* @brief Returns a random video game platform.
Expand All @@ -38,7 +38,7 @@ class VideoGame
* VideoGame::platform() // "Playstation 5"
* @endcode
*/
static std::string platform();
static std::string_view platform();

/**
* @brief Returns a random video game studio name.
Expand All @@ -49,6 +49,6 @@ class VideoGame
* VideoGame::studioName() // "Activision Blizzard"
* @endcode
*/
static std::string studioName();
static std::string_view studioName();
};
}
22 changes: 10 additions & 12 deletions src/modules/videoGame/VideoGame.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
#include "faker-cxx/VideoGame.h"

#include "data/GameTitles.h"
#include "data/Genres.h"
#include "data/Platforms.h"
#include "data/StudioNames.h"
#include "VideoGameData.h"
#include "faker-cxx/Helper.h"


namespace faker
{
std::string VideoGame::gameTitle()
std::string_view VideoGame::gameTitle()
{
return Helper::arrayElement<std::string>(videoGameNames);
return Helper::arrayElement(videoGame::videoGameNames);
}

std::string VideoGame::genre()
std::string_view VideoGame::genre()
{
return Helper::arrayElement<std::string>(videoGameGenres);
return Helper::arrayElement(videoGame::videoGameGenres);
}

std::string VideoGame::platform()
std::string_view VideoGame::platform()
{
return Helper::arrayElement<std::string>(platforms);
return Helper::arrayElement(videoGame::platforms);
}

std::string VideoGame::studioName()
std::string_view VideoGame::studioName()
{
return Helper::arrayElement<std::string>(studioNames);
return Helper::arrayElement(videoGame::studioNames);
}
}
Loading
Loading