mirror of
				https://github.com/onyx-and-iris/Lottery.git
				synced 2025-10-31 13:31:46 +00:00 
			
		
		
		
	SpinButton_Clicked fully implemented
it sets NumbersLabel.Text to different outputs according to the kind of lottery Thunderball lottery added to list of generators
This commit is contained in:
		
							parent
							
								
									5b7f06f8b7
								
							
						
					
					
						commit
						58683834d5
					
				| @ -2,7 +2,7 @@ | |||||||
| { | { | ||||||
|     public partial class MainPage : ContentPage |     public partial class MainPage : ContentPage | ||||||
|     { |     { | ||||||
|         readonly List<IGenerator> generators = [new UKGenerator(), new EuroGenerator(), new SetForLifeGenerator()]; |         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; | ||||||
| 
 | 
 | ||||||
| @ -10,7 +10,7 @@ | |||||||
|         { |         { | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
| 
 | 
 | ||||||
|             List<string> lottos = ["UK", "Euro", "Set For Life"]; |             List<string> lottos = ["UK Lotto", "EuroMillions", "Set For Life", "Thunderball"]; | ||||||
|             LottoPicker.ItemsSource = lottos; |             LottoPicker.ItemsSource = lottos; | ||||||
|             LottoPicker.SelectedIndex = (int)DEFAULT_GENERATOR; |             LottoPicker.SelectedIndex = (int)DEFAULT_GENERATOR; | ||||||
| 
 | 
 | ||||||
| @ -19,8 +19,27 @@ | |||||||
| 
 | 
 | ||||||
|         private void SpinButton_Clicked(object sender, EventArgs e) |         private void SpinButton_Clicked(object sender, EventArgs e) | ||||||
|         { |         { | ||||||
|             List<int> numbers = generator.Generate(); |             Numbers numbers = generator.Generate(); | ||||||
|             Numbers.Text = $"Numbers: {string.Join(", ", numbers)}"; |             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<string> 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) |         private void LottoPicker_SelectedIndexChanged(object sender, EventArgs e) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user