Skip to content

Commit

Permalink
Refactoring as follows:
Browse files Browse the repository at this point in the history
+ Rename FiniteSyllabletSet to SyllableSet
+ Propagate ListExtension method name changes
  • Loading branch information
kesac committed Oct 30, 2021
1 parent b85cce0 commit 1a81440
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Syllabore/Syllabore.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ public static void Main(string[] args)

{
var g = new NameGenerator()
.UsingProvider(new FiniteSyllableSet()
.UsingSyllablePoolSize(16, 8, 4)
.UsingProvider(new SyllableSet(1, 1, 4)
.WithVowels("ae").Weight(2)
.WithVowels("iou")
.WithLeadingConsonants("str").Weight(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Syllabore
// and only returns syllables from that set. This gives
// the appearance of cohesion across all output and is useful
// for simulating names that might come from a specific region.
public class FiniteSyllableSet : SyllableProvider
public class SyllableSet : SyllableProvider
{

public int StartingSyllableMax { get; set; }
Expand All @@ -21,27 +21,19 @@ public class FiniteSyllableSet : SyllableProvider

public bool IsInitialized { get; set; }

public FiniteSyllableSet() : base()
public SyllableSet(int startingMax, int normalMax, int endingMax)
{
this.StartingSyllables = new HashSet<string>();
this.NormalSyllables = new HashSet<string>();
this.EndingSyllables = new HashSet<string>();

this.StartingSyllableMax = 8;
this.NormalSyllableMax = 16;
this.EndingSyllableMax = 8;

}

public FiniteSyllableSet UsingSyllablePoolSize(int startingMax, int normalMax, int endingMax)
{
this.StartingSyllableMax = startingMax;
this.NormalSyllableMax = normalMax;
this.EndingSyllableMax = endingMax;
return this;

}

public FiniteSyllableSet Initialize()
public SyllableSet Initialize()
{
this.IsInitialized = true;

Expand Down Expand Up @@ -73,7 +65,7 @@ public override string NextStartingSyllable()
this.Initialize();
}

return this.StartingSyllables.RandomChoice<string>();
return this.StartingSyllables.RandomItem<string>();
}

public override string NextSyllable()
Expand All @@ -84,7 +76,7 @@ public override string NextSyllable()
this.Initialize();
}

return this.NormalSyllables.RandomChoice<string>();
return this.NormalSyllables.RandomItem<string>();
}

public override string NextEndingSyllable()
Expand All @@ -94,7 +86,7 @@ public override string NextEndingSyllable()
this.Initialize();
}

return this.EndingSyllables.RandomChoice<string>();
return this.EndingSyllables.RandomItem<string>();
}


Expand Down

0 comments on commit 1a81440

Please sign in to comment.