diff --git a/Lottery/MainPage.xaml.cs b/Lottery/MainPage.xaml.cs index f0b3365..7c76a23 100644 --- a/Lottery/MainPage.xaml.cs +++ b/Lottery/MainPage.xaml.cs @@ -2,7 +2,7 @@ { public partial class MainPage : ContentPage { - readonly List generators = [new UKGenerator(), new EuroGenerator(), new SetForLifeGenerator()]; + readonly List generators = [new UKGenerator(), new EuroGenerator(), new SetForLifeGenerator(), new ThunderBallGenerator()]; IGenerator generator; const KindOfLotto DEFAULT_GENERATOR = KindOfLotto.Uk; @@ -10,7 +10,7 @@ { InitializeComponent(); - List lottos = ["UK", "Euro", "Set For Life"]; + List lottos = ["UK Lotto", "EuroMillions", "Set For Life", "Thunderball"]; LottoPicker.ItemsSource = lottos; LottoPicker.SelectedIndex = (int)DEFAULT_GENERATOR; @@ -19,8 +19,27 @@ private void SpinButton_Clicked(object sender, EventArgs e) { - List numbers = generator.Generate(); - Numbers.Text = $"Numbers: {string.Join(", ", numbers)}"; + Numbers numbers = generator.Generate(); + switch (numbers.Kind) + { + case KindOfLotto.Uk: + NumbersLabel.Text = $"Numbers: {string.Join(", ", numbers.Normal)}"; + break; + case KindOfLotto.Euro: + case KindOfLotto.SetForLife: + case KindOfLotto.Thunderball: + if (numbers is NumbersWithSpecial numbersWithSpecial) + { + List output = [ + $"Normal: {string.Join(", ", numbersWithSpecial.Normal)}", + $"Special: {string.Join(", ", numbersWithSpecial.Special)}" + ]; + NumbersLabel.Text = string.Join("\t", output); + } + break; + default: + throw new LottoPickerException($"no NumbersLabel output defined for {numbers.Kind}"); + } } private void LottoPicker_SelectedIndexChanged(object sender, EventArgs e)