Today I wrote a piece of code in C# and I am not happy with it.
The requirement:
At a place, we had to display the number of people who have brought the ticket, segregated as adults and children in different languages.
This resulted in the following possible scenarios (do notice the use of and singular/plural):
-
1 Adult
-
2 Adults
-
1 Adult and 1 child
-
2 Adults and 1 child
-
2 Adults and 2 children
-
1 Child
- 2 Children
Multiply this scenario count with the number of languages as 3. And I have 21 combinations at hand.
I did achieve it using a number of ifs and multiple nested ifs but I don't think it as a good solution. Please advise optimizing the solution.
Aucun commentaire:
Enregistrer un commentaire