diff --git a/02_math_osztaly.txt b/02_math_osztaly.txt index baa531d..266cbc8 100644 --- a/02_math_osztaly.txt +++ b/02_math_osztaly.txt @@ -147,9 +147,9 @@ UML: | + seed(s : unsigned int) { static } | -> srand(s); | + randomize() { static } | -> srand(time(NULL)); | | -| + rand() : int { static } | -> return rand(); -| + randf() : float { static } | -> return rand() / static_cast(RANDOM_32BIT_MAX); -| + randd() : double { static } | -> return rand() / static_cast(RANDOM_32BIT_MAX); +| + rand() : int { static } | -> return ::rand(); +| + randf() : float { static } | -> return ::rand() / static_cast(RANDOM_32BIT_MAX); +| + randd() : double { static } | -> return ::rand() / static_cast(RANDOM_32BIT_MAX); | | | + rand(int m) : int { static } | -> return rand() % m; | | diff --git a/02_math_osztaly/math.cpp b/02_math_osztaly/math.cpp index 03106a3..9bb5581 100644 --- a/02_math_osztaly/math.cpp +++ b/02_math_osztaly/math.cpp @@ -44,22 +44,22 @@ void Math::randomize() { } int Math::rand() { - return rand(); + return ::rand(); } float Math::randf() { - return rand() / static_cast(RANDOM_32BIT_MAX); + return ::rand() / static_cast(RANDOM_32BIT_MAX); } double Math::randd() { - return rand() / static_cast(RANDOM_32BIT_MAX); + return ::rand() / static_cast(RANDOM_32BIT_MAX); } -int rand(const int m) { +int Math::rand(const int m) { return rand() % m; } -int rand(const int from, const int to) { +int Math::rand(const int from, const int to) { return (rand() % (to - from)) + from; } diff --git a/03_monopoly/math.cpp b/03_monopoly/math.cpp index 03106a3..9bb5581 100644 --- a/03_monopoly/math.cpp +++ b/03_monopoly/math.cpp @@ -44,22 +44,22 @@ void Math::randomize() { } int Math::rand() { - return rand(); + return ::rand(); } float Math::randf() { - return rand() / static_cast(RANDOM_32BIT_MAX); + return ::rand() / static_cast(RANDOM_32BIT_MAX); } double Math::randd() { - return rand() / static_cast(RANDOM_32BIT_MAX); + return ::rand() / static_cast(RANDOM_32BIT_MAX); } -int rand(const int m) { +int Math::rand(const int m) { return rand() % m; } -int rand(const int from, const int to) { +int Math::rand(const int from, const int to) { return (rand() % (to - from)) + from; }