Número aleatorio Aprende programación con ejercicios Visual Basic (VB.net)

Lección:

POO Más sobre Clases


Ejercicio:

Número aleatorio 72


Objetivo:

Cree una clase RandomNumber, con tres métodos estáticos:

- GetFloat devolverá un número entre 0 y 1 utilizando el siguiente algoritmo:

semilla = (semilla * a + c) % m
resultado = abs(semilla / m)

- GetInt(max) devolverá un número de 0 a max, usando:
resultado = round(max * GetFloat)

- GetInt(min, max) devolverá un número de min a max (debes crear este totalmente por tu cuenta).

Los valores iniciales deben ser:
m = 233280;
a = 9301;
c = 49297;
semilla = 1;


Código:

Imports System
Namespace Random
    Class RandomNumber
        Private Shared m As Integer = 233280
        Private Shared a As Integer = 9301
        Private Shared c As Integer = 49297
        Private Shared seed As Integer = 1

        Public Shared Function GetFloat() As Single
            seed = (seed * a + c) Mod m
            Return Math.Abs(seed / m)
        End Function

        Public Shared Function GetInt(ByVal max As Integer) As Integer
            Return 0
        End Function

        Public Shared Function GetInt(ByVal min As Integer, ByVal max As Integer) As Integer
            Return 0
        End Function
    End Class
End Namespace