+ 1

Feedback on C# - overall structur

Hi I have just finished the two C# courses and almost all of the Code Coach for C#. I'm new to programming but things are starting to fall in to place, or at least I think so. I would really appreciate if someone with C# knowledge will read my code and give me a little feedback. The task for this Code Coach is to evaluate the best hand in a Poker game (full description is included in the program). The program consists of three classes. class Program { //Read the user input and eventually print the result { class Poker { //Convert the input to some more useful data and evaluate the best hand based on what //hands are available } class RankOfHand { //Determine available hands } I would especially like to know the following: 1. Is the overall structure on the right track. If not how should I have approached it? 2. I don't like all the “else if” when evaluating the best hand, but what is the best alternative? 3. The straight method seems clumsy, is there a smarter way? (you don't have to give me the solution, but a hint would be nice) https://www.sololearn.com/compiler-playground/cKbvVx3u9Wg8 Thanks in advance Kenneth Note: English is not my first language, but hopefully everything makes sens.

24th Oct 2023, 9:30 PM
Kenneth Weile Sørensen
Kenneth Weile Sørensen - avatar
3 Réponses
0
Kenneth Weile Sørensen 1.The structure looks ok if you are going to use OOP 2. maybe use switch expression? https://www.geeksforgeeks.org/switch-expression-in-c-sharp-8-0/ 3.The straight-forward method is probably a functional or imperative, procedural approach. I wouldn't describe it as clumsy. It's probably more concise than OOP. Maybe first convert the input into a more useful format, then use switch expression or pattern matching to determine the result.
4th Nov 2023, 11:16 PM
Bob_Li
Bob_Li - avatar
+ 3
What Is It?
4th Nov 2023, 5:32 PM
Legendflo YT
Legendflo YT - avatar
+ 2
Hi Bob_Li Thanks for the feedback - I really appreciate! -Kenneth
6th Nov 2023, 1:14 PM
Kenneth Weile Sørensen
Kenneth Weile Sørensen - avatar