#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
/*
dado.h
*/
#ifndef DADO_H
#define DADO_H
class Dado
{
public:
int Seed(int max, int min);
int Rolar();
};
#endif
/*
dado.cpp
*/
int Dado::Seed(int max, int min){
srand(time(NULL));
return rand() % max + min;
}
int Dado::Rolar(){
int val_max = 6;
int val_min = 1;
return Seed(val_max, val_min);
}
/*
main.cpp
*/
int main()
{
Dado seed;
Dado dado_1;
Dado dado_2;
cout << "Seed: " << seed.Seed(6,1) << "\n";
cout << "Dado_1: " << dado_1.Rolar() << "\n";
cout << "Dado_2: " << dado_2.Rolar() << "\n";
return 0;
}
ICAgICNpbmNsdWRlIDxpb3N0cmVhbT4KICAgICNpbmNsdWRlIDxjc3RkbGliPgogICAgI2luY2x1ZGUgPGN0aW1lPgogICAgCiAgICB1c2luZyBuYW1lc3BhY2Ugc3RkOwogICAgIAogICAgLyoKICAgIAlkYWRvLmgKICAgICovCiAgICAjaWZuZGVmIERBRE9fSAogICAgI2RlZmluZSBEQURPX0gKICAgICAKICAgIGNsYXNzIERhZG8KICAgIHsKICAgIHB1YmxpYzoKICAgICAgICBpbnQgU2VlZChpbnQgbWF4LCBpbnQgbWluKTsKICAgICAgICBpbnQgUm9sYXIoKTsKICAgIH07CiAgICAgCiAgICAjZW5kaWYKICAgICAKICAgIC8qCiAgICAJZGFkby5jcHAKICAgICovCiAgICBpbnQgRGFkbzo6U2VlZChpbnQgbWF4LCBpbnQgbWluKXsKICAgICAgICBzcmFuZCh0aW1lKE5VTEwpKTsKICAgICAgICByZXR1cm4gcmFuZCgpICUgbWF4ICsgbWluOwogICAgfQogICAgIAogICAgaW50IERhZG86OlJvbGFyKCl7CiAgICAgICAgaW50IHZhbF9tYXggPSA2OwogICAgICAgIGludCB2YWxfbWluID0gMTsKICAgICAgICByZXR1cm4gU2VlZCh2YWxfbWF4LCB2YWxfbWluKTsKICAgIH0KICAgICAKICAgIC8qCiAgICAJbWFpbi5jcHAKICAgICovCiAgICBpbnQgbWFpbigpCiAgICB7CiAgICAgICAgRGFkbyBzZWVkOwogICAgICAgIERhZG8gZGFkb18xOwogICAgICAgIERhZG8gZGFkb18yOwogICAgIAogICAgICAgIGNvdXQgPDwgIlNlZWQ6ICAgIiA8PCBzZWVkLlNlZWQoNiwxKSA8PCAiXG4iOwogICAgICAgIGNvdXQgPDwgIkRhZG9fMTogIiA8PCBkYWRvXzEuUm9sYXIoKSA8PCAiXG4iOwogICAgICAgIGNvdXQgPDwgIkRhZG9fMjogIiA8PCBkYWRvXzIuUm9sYXIoKSA8PCAiXG4iOwogICAgIAogICAgICAgIHJldHVybiAwOwogICAgfQ==