Please rewrite the code, because I don't think I will understand if you just come with an advise |
You will learn much better if you make the changes yourself. Coding is like playing football - you have to practice.
It isn't printing anything because print() prints random_val, but you never set it. Add
random_val = result;
jus before line 33 to fix this.
After you make that change, you'll notice that you get the same value no matter what seed you use. That's because you seed the random number generator at line 26 with the seed parameter to the Get_rand() (the parameter declared at line 24). This is a different variable from the seed member declared at line 16. To fix this with the least code, change Get_rand() at lines 11 and 24 so it takes no parameters. Then change the call at line 55 so it doesn't pass a parameter.
While this will work, it's still not a great solution because if you modify your code to call Get_rand() more than once, you'll find that it always produces the same value. That's because you seed the random number generator each time you call Get_rand(). To fix that problem, you need to seed the random number generator in Set_seed(). But you still have to call it in Get_rand(). The solution to this is to make the random number generator a private member of the class.
There are other improvements that could be made, but I'll stop here for now. See if you can make these changes.