mirror of
https://github.com/onyx-and-iris/Lottery.git
synced 2024-11-21 21:50:48 +00:00
update special identifiers
This commit is contained in:
parent
bc45a4d8f8
commit
1241070a30
@ -2,9 +2,14 @@
|
|||||||
{
|
{
|
||||||
public partial class MainPage : ContentPage
|
public partial class MainPage : ContentPage
|
||||||
{
|
{
|
||||||
readonly List<IGenerator> generators = [new UKGenerator(), new EuroGenerator(), new SetForLifeGenerator(), new ThunderBallGenerator()];
|
readonly List<IGenerator> Generators = [new UKGenerator(), new EuroGenerator(), new SetForLifeGenerator(), new ThunderBallGenerator()];
|
||||||
IGenerator generator;
|
IGenerator Generator;
|
||||||
const KindOfLotto DEFAULT_GENERATOR = KindOfLotto.Uk;
|
const KindOfLotto DEFAULT_GENERATOR = KindOfLotto.Uk;
|
||||||
|
Dictionary<KindOfLotto, string> SpecialIdentifiers = new() {
|
||||||
|
{ KindOfLotto.Euro, "Lucky Stars" },
|
||||||
|
{ KindOfLotto.SetForLife, "Life Ball" },
|
||||||
|
{ KindOfLotto.Thunderball, "Thunderball" }
|
||||||
|
};
|
||||||
|
|
||||||
public MainPage()
|
public MainPage()
|
||||||
{
|
{
|
||||||
@ -14,12 +19,12 @@
|
|||||||
LottoPicker.ItemsSource = lottos;
|
LottoPicker.ItemsSource = lottos;
|
||||||
LottoPicker.SelectedIndex = (int)DEFAULT_GENERATOR;
|
LottoPicker.SelectedIndex = (int)DEFAULT_GENERATOR;
|
||||||
|
|
||||||
generator = generators[LottoPicker.SelectedIndex];
|
Generator = Generators[LottoPicker.SelectedIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpinButton_Clicked(object sender, EventArgs e)
|
private void SpinButton_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Numbers numbers = generator.Generate();
|
Numbers numbers = Generator.Generate();
|
||||||
switch (numbers.Kind)
|
switch (numbers.Kind)
|
||||||
{
|
{
|
||||||
case KindOfLotto.Uk:
|
case KindOfLotto.Uk:
|
||||||
@ -31,20 +36,20 @@
|
|||||||
if (numbers is NumbersWithSpecial numbersWithSpecial)
|
if (numbers is NumbersWithSpecial numbersWithSpecial)
|
||||||
{
|
{
|
||||||
List<string> output = [
|
List<string> output = [
|
||||||
$"Normal: {string.Join(", ", numbersWithSpecial.Normal)}",
|
$"Numbers: {string.Join(", ", numbersWithSpecial.Normal)}",
|
||||||
$"Special: {string.Join(", ", numbersWithSpecial.Special)}"
|
$"{SpecialIdentifiers[numbers.Kind]}: {string.Join(", ", numbersWithSpecial.Special)}"
|
||||||
];
|
];
|
||||||
NumbersLabel.Text = string.Join("\t", output);
|
NumbersLabel.Text = string.Join("\t", output);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new LottoPickerException($"no NumbersLabel output defined for {numbers.Kind}");
|
throw new LottoPickerException($"no NumbersLabel output defined for {numbers.Kind}");
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LottoPicker_SelectedIndexChanged(object sender, EventArgs e)
|
private void LottoPicker_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
generator = generators[LottoPicker.SelectedIndex];
|
Generator = Generators[LottoPicker.SelectedIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user