mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 02:45:41 +00:00
🚚 Rename Random.CoinToss() to Random.NextBoolean()
Fixes #17 and part of #15
This commit is contained in:
parent
bbfdf39d09
commit
db43993d56
@ -16,23 +16,25 @@ namespace X10D
|
|||||||
internal static Random Random { get; } = new Random();
|
internal static Random Random { get; } = new Random();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns either <see langword="true" /> or <see langword="false" /> based on <paramref name="random" />'s next
|
/// Returns either <see langword="true" /> or <see langword="false" /> based on the next generation of the current
|
||||||
/// generation.
|
/// <see cref="System.Random" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="random">The <see cref="System.Random" /> instance.</param>
|
/// <param name="random">The <see cref="System.Random" /> instance.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// Returns <see langword="true" /> or <see langword="false" /> depending on the return value
|
/// <see langword="true" /> if the return value from <see cref="System.Random.NextDouble()" /> is greater than or
|
||||||
/// from <see cref="System.Random.Next(int)" />.
|
/// equal to 0.5
|
||||||
|
/// -or-
|
||||||
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="random" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="random" /> is <see langword="null" />.</exception>
|
||||||
public static bool CoinToss(this Random random)
|
public static bool NextBoolean(this Random random)
|
||||||
{
|
{
|
||||||
if (random is null)
|
if (random is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(random));
|
throw new ArgumentNullException(nameof(random));
|
||||||
}
|
}
|
||||||
|
|
||||||
return random.Next(2) == 0;
|
return random.NextDouble() >= 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user