| 1 |
figdor32 |
2 |
using System; |
| 2 |
|
|
using System.Collections.Generic; |
| 3 |
|
|
using System.Linq; |
| 4 |
|
|
using System.Text; |
| 5 |
|
|
using System.Threading.Tasks; |
| 6 |
|
|
|
| 7 |
|
|
namespace TELTest { |
| 8 |
|
|
internal class Utilities { |
| 9 |
|
|
const string LETTER_ORDER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
| 10 |
|
|
public const string ALPHANUMERIC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890"; |
| 11 |
|
|
public static Random SharedRandom { get; } = new Random(); |
| 12 |
|
|
public static string RandomString(int length = 7) { |
| 13 |
|
|
StringBuilder sb = new StringBuilder(length); |
| 14 |
|
|
for (int i = 0; i < length; i++) |
| 15 |
|
|
sb.Append(ALPHANUMERIC[SharedRandom.Next(0, ALPHANUMERIC.Length)]); |
| 16 |
|
|
return sb.ToString(); |
| 17 |
|
|
} |
| 18 |
|
|
public static string NumberToLetter(int num) { |
| 19 |
|
|
if (num < 26) return LETTER_ORDER[num] + ""; |
| 20 |
|
|
else { |
| 21 |
|
|
int remain = num; |
| 22 |
|
|
string res = string.Empty; |
| 23 |
|
|
while (remain > 0) { |
| 24 |
|
|
int let = remain % 26; |
| 25 |
|
|
res = LETTER_ORDER[let] + res; |
| 26 |
|
|
remain -= let; |
| 27 |
|
|
} |
| 28 |
|
|
return res; |
| 29 |
|
|
} |
| 30 |
|
|
} |
| 31 |
|
|
public static string OdmianaPL(int number, string str = "Punkt") { |
| 32 |
|
|
return str + ( |
| 33 |
|
|
number == 0 ? "ow" : |
| 34 |
|
|
number == 1 ? "" : |
| 35 |
|
|
number >= 2 && number < 5 ? "y" : |
| 36 |
|
|
"ow" |
| 37 |
|
|
); |
| 38 |
|
|
} |
| 39 |
|
|
} |
| 40 |
|
|
} |