Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [ub] C standard library headers in C++ are in the pattern of <c[library-name]> instead of <[library-name].h>
- // stdlib.h -> cstdlib, stdio.h -> cstdio, etc.
- #include <functional>
- #include <iostream>
- #include <random> // [ub] Using C++ random instead of old school C random
- #include <string>
- // [ub] Try not to import entire namespaces if you can get away with it (just specific things you're using)
- using std::cout;
- using std::endl;
- class menstats { // [ub] You could call this MentalStats or something... it's 2019, we're not limited to 80 character line lengths anymore ;)
- //data for mental ability
- public:
- // [ub] Is there a good reason for these to be publicly mutable? Also naming comment above applies here.
- int perce; //oblivious / keen eyed
- int spati; //bad spatial reasoning / good spatial reasoning
- int intel; //bad patern recog / good patern recog
- menstats(const std::function<int(void)> &randomizer) {
- perce = randomizer();
- spati = randomizer();
- intel = randomizer();
- }
- menstats (const std::function<int(void)> &fuzzer, const menstats &a, const menstats &b) {
- perce = (((a.perce + b.perce) / 2) + fuzzer());
- spati = (((a.spati + b.spati) / 2) + fuzzer());
- intel = (((a.intel + b.intel) / 2) + fuzzer());
- }
- };
- int main() {
- std::random_device device;
- std::default_random_engine generator{device()};
- std::uniform_int_distribution<int> distribution(1, 10);
- auto randomizer = std::bind(distribution, generator);
- std::uniform_int_distribution<int> fuzzyDistribution(0, 3);
- auto fuzzer = std::bind(fuzzyDistribution, generator);
- menstats one(randomizer);
- menstats two(randomizer);
- menstats three(fuzzer, one, two);
- cout << one.perce << endl;
- cout << one.spati << endl;
- cout << one.intel << endl;
- cout << two.perce << endl;
- cout << two.spati << endl;
- cout << two.intel << endl;
- cout << three.perce << endl;
- cout << three.spati << endl;
- cout << three.intel << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement