-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepeat.cs
More file actions
41 lines (37 loc) · 1 KB
/
Copy pathRepeat.cs
File metadata and controls
41 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Generator
{
public class Repeat : IGenerate
{
private int _min;
private int _max;
private IGenerate _item;
private string _separator;
public Repeat(int min, int max, IGenerate item, string separator = " ")
{
_min = min;
_max = max;
_item = item;
_separator = separator;
}
public string Generate()
{
int repeat = _min + RandomizerFactory.Random.GetNext(_max - _min);
StringBuilder sb = new StringBuilder();
if (repeat > 0)
{
sb.Append(_item.Generate());
for (int i = 1; i < repeat; i++)
{
sb.Append(_separator);
sb.Append(_item.Generate());
}
}
return sb.ToString();
}
}
}