summaryrefslogtreecommitdiff
path: root/include/book_store/random.hh
diff options
context:
space:
mode:
Diffstat (limited to 'include/book_store/random.hh')
-rw-r--r--include/book_store/random.hh66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/book_store/random.hh b/include/book_store/random.hh
new file mode 100644
index 0000000..e279feb
--- /dev/null
+++ b/include/book_store/random.hh
@@ -0,0 +1,66 @@
+#ifndef RANDOM_HH
+#define RANDOM_HH
+
+#include <array>
+#include <cstddef>
+#include <random>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "book.hh"
+#include "person.hh"
+
+namespace book_store::utility::random {
+constexpr std::array<std::string_view, 50> names = {
+ "James", "John", "Robert", "Michael", "William", "David",
+ "Richard", "Joseph", "Thomas", "Charles", "Daniel", "Matthew",
+ "Anthony", "Donald", "Mark", "Paul", "Steven", "Andrew",
+ "Kenneth", "Joshua", "George", "Kevin", "Brian", "Edward",
+ "Ronald", "Timothy", "Jason", "Jeffrey", "Ryan", "Jacob",
+ "Gary", "Nicholas", "Eric", "Stephen", "Jonathan", "Larry",
+ "Justin", "Scott", "Brandon", "Frank", "Benjamin", "Gregory",
+ "Samuel", "Raymond", "Patrick", "Alexander", "Jack", "Dennis",
+ "Jerry", "Tyler"};
+constexpr std::array<std::string_view, 50> book_title_parts = {
+ "The", "A", "An", "In", "Of", "And",
+ "To", "For", "With", "On", "At", "By",
+ "From", "Up", "About", "Into", "Over", "After",
+ "Between", "Out", "Against", "Under", "Without", "Within",
+ "Along", "Across", "Behind", "Beyond", "Through", "Around",
+ "Among", "Upon", "Beside", "Toward", "Against", "Upon",
+ "Amongst", "Between", "Within", "Without", "Underneath", "Under",
+ "Over", "Into", "About", "Up", "From", "By",
+ "At", "On"};
+constexpr std::array<std::string_view, 10> publishers = {
+ "Penguin", "Random House", "HarperCollins", "Simon & Schuster",
+ "Macmillan", "Hachette", "Harlequin", "Scholastic",
+ "Pearson", "Houghton Mifflin"};
+
+class book_random_engine {
+private:
+ std::mt19937 _random_number_generator;
+
+public:
+ book_random_engine() : _random_number_generator(std::random_device{}()) {}
+ explicit book_random_engine(std::mt19937 random_number_generator)
+ : _random_number_generator(random_number_generator) {}
+ book_random_engine(const book_random_engine &) = default;
+ book_random_engine(book_random_engine &&) = default;
+
+ auto title() -> std::string;
+ auto name() -> std::string;
+ auto author() -> consumer::person;
+ auto authors() -> std::vector<consumer::person>;
+ auto publisher() -> std::string;
+ auto isbn() -> std::string;
+ auto price_usd() -> double;
+ auto copy_count() -> product::book::size_type;
+ auto id() -> std::size_t;
+
+ auto operator=(const book_random_engine &) -> book_random_engine & = default;
+ auto operator=(book_random_engine &&) -> book_random_engine & = default;
+};
+} // namespace book_store::utility::random
+
+#endif // RANDOM_HH