From 304437b834e8c87687f68333ae67a13ee1377a73 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Wed, 12 Jun 2019 21:47:51 +0200 Subject: Adjust Codestyle --- dsa/DSALib/Auxiliary/Dice.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'dsa/DSALib/Auxiliary/Dice.cs') diff --git a/dsa/DSALib/Auxiliary/Dice.cs b/dsa/DSALib/Auxiliary/Dice.cs index 0bfabeb..36a4748 100644 --- a/dsa/DSALib/Auxiliary/Dice.cs +++ b/dsa/DSALib/Auxiliary/Dice.cs @@ -1,24 +1,22 @@ using System; using System.Linq; -namespace DSALib.Auxiliary -{ +namespace DSALib.Auxiliary { public static class Dice // roll it! { private static readonly Random Rnd = new Random(); - public static int Roll(int d = 20) - { + public static int Roll(int d = 20) { return Rnd.Next(d) + 1; } - public static int Roll(string input) - { + public static int Roll(string input) { var strings = input.ToLower().Split(new[] {'w', 'd'}, 2, StringSplitOptions.RemoveEmptyEntries).ToList(); - + if (strings.Count != 2) - throw new ArgumentException($"{input}: does not satisfy the format requirements( dice count (d|w) die size)"); + throw new ArgumentException( + $"{input}: does not satisfy the format requirements( dice count (d|w) die size)"); var count = Convert.ToInt32(strings[0]); var d = Convert.ToInt32(strings[0]); @@ -26,13 +24,11 @@ namespace DSALib.Auxiliary return Roll(count, d); } - public static int Roll(int count, int d) - { + public static int Roll(int count, int d) { if (d <= 0 || count <= 0) return 0; var sum = 0; - for (var i = 0; i < Math.Abs(count); i++) - { + for (var i = 0; i < Math.Abs(count); i++) { var roll = Roll(d); sum += roll; } -- cgit v1.2.3-54-g00ecf