Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
ReadableIdGenerator Implemented (#13)
Browse files Browse the repository at this point in the history
* start

* emoji

* Implemented ReadableIdGenerator

* includingNumbers
  • Loading branch information
RohrerF authored Apr 24, 2019
1 parent fd114aa commit e95ead1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Domain/ReadableIdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

namespace UltimateTicTacToe.Domain
{
public class ReadableIdGenerator
public static class ReadableIdGenerator
{
private const string Characters = "ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvwxyz123456789";
private const int IdLength = 7;

public static string NewId()
{
return Guid.NewGuid().ToString("N");
Random random = new Random();
int characterAmount = Characters.Length;
char[] id = new char[IdLength];

for (int i = 0; i < IdLength; i++)
{
int index = random.Next(0,characterAmount);
id[i] = Characters[index];
}

return new string(id);
}
}
}
}

0 comments on commit e95ead1

Please sign in to comment.